Sorry I'm new to this. We were supposed to save a random list of numbers and open it with this program. I can't name those things the same? Then what should I name them? I thought they were supposed to be the same as the file I'm opening.
The names of your variables has absolutely nothing to do with the names of the files you are working with. You can, however, store the name of a file inside of a string variable.
On line 8, you create a variable named randomtext. This variable just so happens to be an input file stream. Then on the very next line you (try to) create another variable with the same name. You probably wanted to do this instead:
8 9 10 11
string filename;
cin >> filename;
ifstream in (filename.c_str());
if(in)
Thank you. I kept thinking filename meant that I had to put in the name of the file. But I still need to get the file in the file somehow. I need to use it for math and I need to open and close it. Randomtext is not declared. How would I declare a file?