+ 1

%c,%d,%f this format id are useful in c++??

to print alphabet I am using printf("%c",k); in c. but this is helpful in cpp??

8th Feb 2018, 4:18 AM
prajakta ingavale
4 Answers
+ 6
Most C functions are available in C++, and many more. So you may use format specifiers with printf in C++ as well. But for stream I/O like in cout, cin or fstream objects, these specifiers are no longer used.
8th Feb 2018, 4:26 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 5
@Ace Thank you sir, I didn't know that. I have changed the answer.
8th Feb 2018, 11:05 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
Personally, I prefer to continue using printf in c++ over cout. Plus you'll need those to format other strings that aren't being output to the console.
8th Feb 2018, 4:25 AM
Jesse Bayliss
Jesse Bayliss - avatar