cin and cout
I'm really new to C++ but i ahve a problem with cin and cout.
in a simple program like eg.
I have used cin and cout thinking it would print the text in some sort of console window but instead it prints it in a text file called stdout. The input only works if I create another text file in the same folder called stdin and type the input in there and save before running the program. Is this what it should do. If so then what other functions could I used to make it print in a console window?
cout<<"Your number was "<<x;
I am using Macintosh Programmers' Workshop on the Mac.
i'm no mac programming expert by any stretch of the imagination, but here are my thoughts on this:
standard input in windows is the keyboard and standard output is the console window (or monitor). From what i have heard of mac, they have no DOS, so they can't have a console window to ouput stuff to. Have you tried using printf() and scanf()?
heh. just out of interest have you ever used a Mac?
the keyboard is still the primary input method and the monitor the primary output method, I'm pretty sure. But you're right that there is no DOS.
printf() does the same thing as cout (ie prints to a file).
I thought that's what it meant, the f in printf standing for file and cout meaning console out.
Anyone else have any ideas?
all I really want to know is "Is cout supposed to print to a file?"
cout prints to standard output.. maybe you have to redefine what standard output is when you are attempting to write a console app on mac? i'm not sure... i don't think there are many mac users around here.. i'm not even sure if you are supposed to write console programs with a mac.
well. I don't see why you shouldn't be able to write console apps on Mac but thanks anyway.
I'll try and investigate this elsewhere as well.