I have a code here which I do not believe has any errors, but when I try to compile my code it can not read from the file I had saved with the source code. It's just a simple txt file. On top of that I could not read from a .h file I tried to save in the same file as the source code and had to create the header file inside my program. I hope the header file problem will be solved with the txt problem. Here is the code. The code never passes through int Loadmovies()
You are declaring FILE_NAME as an array of 30 chars, but you are only using the first 13 positions. This means that the other 17 are garbage data, and when you pass the string to ifstream, it tried to open the filename plus the garbage data.
Still no good, I did take into consideration the FILE_NAME may have been getting in the way, and just bypassed the file name and put the file name right in the open file line. I still received the same results! :( could there be a possible problem in some type of settings in c++ that won't allow the directory to work or something?
You are declaring FILE_NAME as an array of 30 chars, but you are only using the first 13 positions. This means that the other 17 are garbage data, and when you pass the string to ifstream, it tried to open the filename plus the garbage data.
This isn't true of arrays which are initialized with values or any arrays at global scope (which have the memory zero'd before main is entered,) and is beside the point since the array is large enough to hold the c-string it is storing and c-strings are terminated by nul characters. open will see nothing beyond the nul character stored therein.
I suspect you just have your data file in the wrong place. If you're using an IDE, one of the easiest ways to figure out the directory you need to place the file in is to open a non-existent file for output and then check through your directories to see where it was created. That is the directory where your data file should be placed. If you're not using an IDE, then the file should just be in the same directory as your executable.
By default, the project directory is set as the working directory in Visual Studio, so it would normally need to be in the projectname/projectname/ directory. One other problem I've seen people run into is hidden file extensions, so what looks like a file named MovieData.txt is actually a file named MovieData.txt.txt.
Thank you so much cire, your last paragraph solved my problem. When I named my files, like "lol.h" it was a text file with my executable file. When I added a .txt to the end of my file locations the program worked. Thank you so much for the help!