C++ printf function (#14) 🖨️

preview_player
Показать описание
C++ printf() function tutorial

Coding boot camps hate him! See how he can teach you to code with this one simple trick...

Bro Code is the self-proclaimed #1 tutorial series on coding in various programming languages and other how-to videos in the known universe.
Рекомендации по теме
Комментарии
Автор

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
// printf()

string make = "Ford";
string model = "Mustang";
int year = 2021;
double price = 9999.000;
char for_sale = 'Y';

printf("Your car is made by: %s", "Ford"); cout << endl;
printf("Your car is made by: %s", make.c_str()); cout << endl;
printf("Your car is a: %s %s", "Ford", "Mustang"); cout << endl;
printf("Your car is a: %s %s", make.c_str(), model.c_str()); cout << endl;

printf("The year is: %d", year); cout << endl;
printf("The price is: %f", price); cout << endl;
printf("Is it for sale: %c", for_sale); cout << endl;

printf("The price is: $%.2f", price); cout << endl;
printf("This precedes with blank spaces:%10s", "Ford"); cout << endl;
printf("This precedes with zeros:%010s", "Ford"); cout << endl;
printf("Left justify:%-10s%-10s", "Ford", "Mustang"); cout << endl;

cout << endl;
return 0;
}

BroCodez
Автор

OMG bro, thanks a lot. Thing about printf and string class got me. But your method works! I wish you health and money!!!

smaginaleksei
Автор

Hey @Bro Code, will there ever be a C series on this channel?

joshlazor
Автор

This video has taught me things that have been confusing.

chimdichikezie
Автор

not going to my lectures cause u got me bro

edran
Автор

printf and scanf is always on the upper hand like even if you want to do serious programming, competitive interviews where you want faster executions strategy of print and scanf is the best !

amazon.techspotlight
Автор

I am not a c++ programmer but at first glance this printf function look so stupid...

RealityCheck
Автор

Thank you, one question though. I think I answered my own question as I was typing it out. How would you put like a $ in front of something in the second column with this.

nicholi
Автор

ive liked just commented, already subbed, and added this playlist :)

edran
Автор

after % we have s, d, f, c.. what do they stand for ?

study_with_thor
Автор

great video bro, but the line %010s is not working for me, any help?

brunobollati