| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| First of all, one of the main problems you have is that you aren't checking your errors. UNIX, unlike Mac OS, has had, for many many years, a simple way of printing out the actual error, in a way a human can easily understand. None of the "error -12345" business. The correct way to check the return code from fopen (check the Return section of the manual-page to see how best to check for errors) is as follows. FILE *fp; char *filename = "xxxx"; if( (fp = fopen( filename, "w" )) == NULL ) { perror("Could not open filename"); // either return with an error code, or exit(EXIT_FAILURE) } x-man-page://perror, which is part of the stdio library, will output to stderr, the string given, followed by a colon and space, and the human-readable string that relates to errno, such as "No such file or directory" (which is what you would get if errno == ENOENT) If you want more control, you can use x-man-page://strerror You should always check your return codes. One other problem you have is that you're assuming a folder will be created for you, which fopen will not do. |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/xcode-users/email@hidden This email sent to email@hidden
| References: | |
| >fopen (From: "Carl Smith" <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.