Help with file stream I/O in Visual Studio

I'm sure this is a very simple problem, but I don't understand C++ file stream I/O. I'm not grasping the theory behind how I/O is structured, or how it works.

I am basically copying everything character for character from the examples in my textbook but online and VS compilers both come back with 20+ errors.

How do I build a header file?
What do I put in the header file?
Where do I put my I/O files so that they are recognized by the compiler?

Does anyone have any tips for working with Visual Studio, which I am supposed to be using for my class?

It's not really hard to figure.
You need the <ifstream> (for taking information) or <fstream> (for putting information) header files.
You declare an object like this:
ofstream NAME;
ifstream NAME;

Then you can use it just like you would use cin or cout.
A header file is a file of extension '.h'. Header files are used for declaration of classes, functions and etc. You can add a header file in Visual Studios by pressing 'Ctrl + Shift + A' and then you can name your header file there. The header file will be created in the main project folder. All your I/O files can be kept anywhere on your PC. You just need to tell the compiler where they are located so long as they are accessible your program can access them. But it is a good practice to keep all your files in the project folder. Hope this answers some of your questions.

If you need further assistance then do contact me.
Topic archived. No new replies allowed.