Re: Dealing with slash characters with fopen?
Re: Dealing with slash characters with fopen?
- Subject: Re: Dealing with slash characters with fopen?
- From: Shawn Erickson <email@hidden>
- Date: Wed, 29 Nov 2006 21:31:49 -0800
On Nov 29, 2006, at 8:34 PM, Scott Ribe wrote:
Should I turn the slash into a colon?
Probably. This is generally how OS X deals with POSIX paths, though I
haven't actually tried it with fopen...
The POSIX layer expects the "/" character as a path separator.
#include <stdio.h>
int main (int argc, const char * argv[]) {
FILE* fd = fopen("/tmp/testfile.txt", "w");
fprintf(fd, "Hello");
fclose(fd);
char tmpstring[60] = {0};
fd = fopen("/tmp/testfile.txt", "r");
fscanf(fd, "%s", &tmpstring);
fclose(fd);
printf("%s", tmpstring);
return 0;
}
HelloMacPro:~/FOpenTest shawnce$ gcc main.c
MacPro:~/FOpenTest shawnce$ ./a.out
Hello
MacPro:~/FOpenTest shawnce$ ls /tmp/*.txt
/tmp/testfile.txt
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden