cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
difference of cout and myfile
difference of cout and myfile
Mar 1, 2012 at 10:28am UTC
yhangel
(72)
i have this code..
#include <iostream>
#include <fstream>
#include <string>
main()
{
ostream myfile;
string myinput;
}
the question is..
what is the difference of
cout<<myinput; in myfile<<myinput; ?
if i want to save it on file at the same time print it in console,, should i put both?
Mar 1, 2012 at 10:55am UTC
hamsterman
(4538)
The difference is that cout does not write to your file (although it could be redirected..). cout is also an ostream object. What differs is the target.
If you want to have your input in two places, you'll have to write it two times.
Mar 1, 2012 at 10:57am UTC
yhangel
(72)
so if i want it to appear in my console and write it in my file.. i should put both?
Mar 1, 2012 at 4:12pm UTC
hamsterman
(4538)
yes
Topic archived. No new replies allowed.