+ 9
printf(), cout <<"".,,, what the difference?
printf() and cout <<"" what the difference? this tow in c++
9 Respostas
+ 6
Both cout and printf are used for outflow of data i.e. output.
cout is a output stream while printf is a function.
cout requires header file iostream while printf requires header file stdio.h
cout is used only by c++ while printf can be used by both c and c++.
+ 6
printf is used for printing out formatted strings or integers taken in as arguments its similar string concatenation but the plus sign is not needed.
cout used to print out strings or integers to console.
+ 2
also, if you need to use cout you should include iostream library, and if you need to use printf you should include cstdio library
+ 1
no difference, both used for the same purpose.
+ 1
Ali Hassan So why do they both exist?
+ 1
cout usually used in c++ interface, printf usually used in c,c# or MATLAB. but there purpose is to show output.
+ 1
generally both are used for same purpose ,i.e to print something.the only difference is that both are defined in two separate header file,studio.h for printf(),and iostream.h for cout<<"";..
0
printf occurs in c where course occurs in c++
- 3
Its easy right