File not created with fopen and relative reference syntax not working
Hey very simple problem. I've been searching the site to see if I did anything wrong and I had to fail because I still get the wrong results (semantic error). Problem #1: Every time I use fopen with the "w" (or write) mode the file with whatever name given is not created which brings us to the second problem. Problem #2: Correct me if I am wrong (syntax might of changed due to updates), but as I know according to Dave Mark's "Learn C on the Mac" he specifies as filename paths as the following:
All of the following are the same:
Location from root: /Users/davemark/test/myFile.text
Location from source code file: ./myFile.text meaning myFile.text is in the same folder as the source code file
or: ../myFile.text meaning myFile.text is in the parent directory from the source code file
Location from home directory: ~/test/myFile.text
I think that problem number #1 is a result of problem #2 and it is because every time I use fopen I specify the filename path from the source code file. I don't want to use the location from root every time so heres my code, what am I doing wrong?:
1) until you completely understand how paths work in relation to your IDE vs Program, use the full path.
2) You don't check to see if the file was opened. It probably was, just not where you expected. Always error check after anything that might not work.
I did try just the name but I think WaltP is right: I have to use the full path; also I figured out why the path wasn't working. Dave Mark specifies that the different filename paths in reference to the file are limited to the unix and mac os x compiler (via terminal) so xcode doesn't ever read the filename as such. Also WaltP I did check to see if it was open and there was an address assigned the file (*userfile). Thank you all