Why would you use iostreams when stdio functions compile so much smaller?
such as
cout << "hello, world!" << endl;
or
printf("hello, world!\n");
the latter compilers much smaller....so why use the first one?
Why would you use iostreams when stdio functions compile so much smaller?
such as
cout << "hello, world!" << endl;
or
printf("hello, world!\n");
the latter compilers much smaller....so why use the first one?
cout will always do the right thing, because it is type safe
cout << "the value is " << myfloat;
vs.
printf("the value is %d ", myfloat );
Some compilers can warn you that %d doesn't print a float, but many don't. The code will compile just fine, and may even produce some expected answers, but it is wrong.
cout can use overloaded functions.
cout << "The values in class are " << myclassvar;
vs.
printf( "The values in class are %?????? ", myclassvar );
printf() cannot be extended in a portable way to output entire classes.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I see, interesting.
tell me salem, do you prefer to program in C or C++?