My task was to write a program that reads several lines of information from a data file and prints each word of the file on s separate line of an output file followed by the number of letters in that word. I also needed to print a count of words in the file on the screen when done.
Here is my code:
// File: Reading in file and printing out file> cpp
The code does not read the data file, I can't find the reason why, and this has bothered me for three weeks. Not even my professor for my programming class couldn't find the issue. Anyone want to give a try?
The problem is that the code will not open and in file to read a personal data file, the code by its self can be debugged without issues. But it continues to state the exit failure for the InFile.
And you're positive that the file you're reading from exists and is named correctly? It works fine for me when using a different file name that I have stored on my own computer, regardless of whether or not I'm using a mapped drive or a file in the same folder as the .cpp file.
Try changing your code to #define inFile "name.txt" and place your text file in the same folder as your .cpp file. We'll try and take as many factors out of this equation as we can.