^
cout << "Hello World!";
printf("Hello World!");
system("echo Hello World!");
other
^
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
More a general discussion topic btw:
cout.
What about write, fprintf, and fwrite?
Who the hell uses system("echo ...")!? Indeed bad form.
I don't think you can compare printf(), and cout, since one is C and the other is C++...
I think C++ is much better since you don't have problems with data types.
none...
Lets not get carried away and go around saying stuff like that.
Example
This will be a problem... Granted you do have to do more work to break cout my example (though extreme) isn't too uncommon.Code:std::cout << *(std::string *)55 << std::end;
system ("echo ...") makes me barf
i believe even in C++, printf () has its place, particularly in something that requires heavily formatted output, with bunches of numbers all over the place in different formats. as far as printf () being unsafe, get gcc, it will warn you of printf () and format string not coinciding with passed args at compile time.
whoever said write and fwrite, they are best used to do other things.
hello, internet!
I just use all three
Code:#include <iostream> #include <cstdlib> using namespace std; int main ( ) { printf( "%s", cout << system("echo hello world") ? "" : "" ); return 0; }
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.
Salem that is the most beautifully written code I've ever seen.
Can you please explan?Originally posted by moi
system ("echo ...") makes me barf
i believe even in C++, printf () has its place, particularly in something that requires heavily formatted output, with bunches of numbers all over the place in different formats
none...
exactly what wouldyou like me to explain?Originally posted by ammar
Can you please explan?
hello, internet!
Sorry it wasn't clear in my furst post, I was in the computer lab in the University, I had a class to catch.
I want to ask why would we use printf(), to get "formatted output, with bunches of numbers all over the place in different formats"
none...
are you familiar with how to use both printf and ostream (cout, cerr, and friends)?? if not, read something on those first. also, what i said is just my opinion, not fact
hello, internet!
Now it's clear, because I know that everything done by printf(), can be done with cout, and I didn't understand why did you say that, it sounded like a fact, and I was confused...
none...
what i was trying to say is that in such situations, i find printf easier and more sensible to deal with than ostream
hello, internet!
it depends on the out put that you want to display on the monitor
I often use , cout:
but in some cases I use system (" echo string-out-put"); When I need to show some chioces that the user should read before he typed in his chioce.
C++
The best