Feb 13, 2012 at 11:28pm UTC
Input files read data from a file, and output files write data to a file.
So, unless you open a file containing an integer value, inFile >> a;
doesn't read anything.
EDIT: spelling
Last edited on Feb 13, 2012 at 11:29pm UTC
Feb 13, 2012 at 11:52pm UTC
oh, how would you input the value for age; would you just use a cin? i was trying to avoid cins and couts though.
Feb 13, 2012 at 11:55pm UTC
You could create a file called input.txt with a number in it. You could do this with a standard text editor.
Last edited on Feb 13, 2012 at 11:56pm UTC
Feb 13, 2012 at 11:57pm UTC
If you want to get user input from the console then yes, you have to use cin >>
.
Feb 14, 2012 at 12:05am UTC
Once you've opened the file (ie. you have said ifstream inFile;
) you can just use in >> a;
.