Tuesday, 14 February 2017

c - fopen() returning a NULL pointer, but the file definitely exists

Is it possible that the filename is not really "data.txt"?




On Unix, filenames are really byte strings not character strings, and it is possible to create files with controls such as backspace in their names. I have seen cases in the past in which copy-pasting into terminals resulted in files with ordinary-looking names, but trying to open the filename that appears in a directory listing results in an error.



One way to tell for sure that the filenames really are what you think they are:



$ python
>>> import os
>>> os.listdir('.')

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...