I completely enter the file address for the code test.
But ''else'' is constantly executed. What could be the problem? The test file and the code itself with the whole solution are in the same folder.
Write exactly what you are typing into the program.
- Does your path contain spaces?
- Is it a relative path or an absolute path?
Using cin >> with a char array is dangerous because there is no way to limit the size of the buffer you're feeding into. Using getline will prevent this buffer overflow and allow for spaces.
I assume chebyrek's issue was the spaces, but cool, I didn't know that was a thing you could do on the input side. I can't find whether or not that adds a null-terminator, so I guess you should do it yourself just in case.
>> setw(n) specifies the total size of the available buffer including the terminating null-char. The resultant char array is null-terminated in all cases. So a max of n - 1 chars are input.