Reputation: 265
I am new to file I/O, and I am writing a program in C to read a file that I already created. The examples in the book I have do not use literals with spaces. I was wondering if:
#define kErrorLog "/Dropbox/Dev/Learn%20C%20on%20Mac/Error%20Log"
would give me the appropriate path that corresponds to user/dropbox/dev/Learn C on Mac/Error Log
.
Upvotes: 0
Views: 66
Reputation: 241701
No, you should just use spaces:
#define kErrorLog "/Dropbox/Dev/Learn C on Mac/Error Log"
The %20
escape is interpreted by web servers. Filenames are just character strings.
Upvotes: 2
Reputation: 129011
No; the file name need not be URL-encoded like that. You can include spaces normally:
#define kErrorLog "/Dropbox/Dev/Learn C on Mac/Error Log"
In general, there is no need to escape file names in C. If you're putting a file name directly in your code, you might need to escape problematic characters inside a string literal (for example, backslashes), but once you have it in a string, no modifications need to be made to that string to use it as a file name.
Upvotes: 1