• 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
writing huge C-array to a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

writing huge C-array to a file


  • Subject: writing huge C-array to a file
  • From: PGM <email@hidden>
  • Date: Fri, 21 Jul 2006 11:04:12 -0400

Hey everybody

In my app, I have a document containing a potentially huge two-dimensional C-array filled with doubles that I need to write to a file (with a user-specified number of decimals). My original plan was to use NSDocument's "dataRepresentationOfType" and fill an NSMutableString with the text and use that. However, this takes forever because the NSMutableString has to allocate additional memory again and again ("initWithCapacity" did not help much).

What I did then is to use "writeToFile:ofType:" and then use plain C to write the data to a file:

    	FILE *writing;
     double **matrix = [myData distanceMatrix];
     const char *out_name;
     out_name = [fileName cString];
     writing = fopen(out_name, "w");
	fprintf(writing, everything); //looping over the matrix

This works, but I am afraid that it will break when the fileName contains non-ASCII characters. Is there another fast way to write a large C-array to a file that does work with non-ASCII filenames?

Thanks in advance, Patrick

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: writing huge C-array to a file
      • From: Bill Bumgarner <email@hidden>
    • Re: writing huge C-array to a file
      • From: Tommy Nordgren <email@hidden>
    • Re: writing huge C-array to a file
      • From: Dado Colussi <email@hidden>
  • Prev by Date: Universal builds/intel and core data fetch requests
  • Next by Date: Re: bindings, tables and custom sort selector
  • Previous by thread: Universal builds/intel and core data fetch requests
  • Next by thread: Re: writing huge C-array to a file
  • Index(es):
    • Date
    • Thread