+ 1

Is cout in c++ is as same as printf in c?I am new to programming.so anyone can elaborate please?

5th Jul 2017, 12:45 AM
Bharath Naidu Yenumula
Bharath Naidu Yenumula - avatar
10 Réponses
+ 5
no man printf is formatting, cout is just to display output
5th Jul 2017, 12:53 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
iirc it was sth like printf("%s%s", "Hello ", "world!") idk i learned from my friend who learned C i might get it wrong but its actually similar to .format() from py3
5th Jul 2017, 4:02 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
yeah they both produce output, im not rly knowledgeable about this tbh
5th Jul 2017, 4:13 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 1
@Bharath Cout is used for output. Try not to worry about comparing the two languages for now. I do not see the value in knowing the exact difference, between cout and printf if you are just starting.
5th Jul 2017, 4:22 AM
Manual
Manual - avatar
+ 1
cout = C output cin = C input
5th Jul 2017, 4:23 AM
Manual
Manual - avatar
+ 1
@manual Thanks for answering! You've cleared my doubt!
5th Jul 2017, 4:28 AM
Bharath Naidu Yenumula
Bharath Naidu Yenumula - avatar
+ 1
@Bharath You're welcome!
5th Jul 2017, 4:30 AM
Manual
Manual - avatar
0
@Cheese What do you mean, by printf is for formating?
5th Jul 2017, 3:57 AM
Manual
Manual - avatar
0
@Cheeze I think I know what you mean. There is a way to substitute string values like %d, using pointers. edit Otherwise printf is I believe a funtion for output, as well as formating.
5th Jul 2017, 4:12 AM
Manual
Manual - avatar
0
@cheeze same, I just use it as well as puts() - learned that recently
5th Jul 2017, 4:19 AM
Manual
Manual - avatar