I want to know what difference I use in C ++ cout
and printf
, is it all the same?
I want to know what difference I use in C ++ cout
and printf
, is it all the same?
No, they are completely different, although they have more or less similar purposes.
cout
works with streams of data. These streams can be customized for each data type.
The function printf()
is a very simple normal function originally created for C language and has been retained for reasons of compatibility and because in some cases it may be more appropriate than cout
.
Generally, cout
is not only more convenient and simple to use in C ++, but it also tends to perform better. You have a inbound partner question .
See more about cout
here .
And how does printf()
work.
#include <stdio.h>
#include <iostream>
int main(){
printf("Eu posso misturar printf com cout?");
cout<<"Em?";
return 0;
}