• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dealing with slash characters with fopen?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Dealing with slash characters with fopen?
      • From: Shawn Erickson <email@hidden>
References: 
 >Re: Dealing with slash characters with fopen? (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: Linking woes
  • Next by Date: Re: Dealing with slash characters with fopen?
  • Previous by thread: Re: Dealing with slash characters with fopen?
  • Next by thread: Re: Dealing with slash characters with fopen?
  • Index(es):
    • Date
    • Thread