What is the difference between console I/O functions and stream I/O functions? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between console I/O functions and stream I/O functions?

please help confusion

18th Mar 2017, 6:03 PM
Serjeel Ranjan
Serjeel Ranjan - avatar
2 Answers
+ 3
Console I/O is as it says interacts directly with console or terminal, whichever you use. Stream I/O are little different. I'll try to explain it. Let's say we want to output a string "Hello world". One way is, cout << "Hello world"; This way can only show output wherever cout is linked to, like console. Other way can be string myString =" Hello world"; Now, this is little better. We can use this variable to show it on console, cout << myString; Or, write it in a file ofstream myFile; myFile.open("file.txt"); myFile << myString; myFile.close(); Or, write it on ANY other device! Streams are something like that. You can use them to store some data, and then flush them anywhere you want. I hope it's a right explanation. Anyone else if has better explanation or corrections, please due share.
19th Mar 2017, 3:54 PM
Manpreet Singh
Manpreet Singh - avatar
+ 1
oooooo😉
19th Mar 2017, 4:05 PM
Serjeel Ranjan
Serjeel Ranjan - avatar