file input output operation issues

sorry
Last edited on
How do you know your input file opened successfully? How are the data stored within the file? Where in your code are you getting input from the console?
Because all you did was open the file. You never did anything. Cout is for the console, not for files. For file reading and outputting, it's very very similar to cin and cout, in that you're using the same operators, but you're not using those keywords.

1
2
fileObject >> stuff; // reading a file
fileObject << stuff2; // outputting into a file 


Also the reason your integers are such weird values is because they're not initialized to anything and are thus trash values. And if you wanted to enter values for your integers, you never called cin.
.
Last edited on
If you mean where you should put it inside VS where you have the Add New Item or Add Existing Item thing? No you don't do that. Just put the text file in the same directory as your source/header files. For example if my project folder was on my desktop, it would go something like

C:\*user*\*computername*\Desktop\*projectname*\*the_other_projectname*\file.txt

It should go in the exact same folder you see ALL your source and header files.
Topic archived. No new replies allowed.