Thread: Help with file read/write

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Quote Originally Posted by bluej322 View Post
    I'm using TextEdit, and i made sure it's plain text(instead of the default rich text format).
    Doesn't matter; TextEdit will change three dots to an ellipsis character for you anyway. (You can watch it happen: open your file in TextEdit, type three dots and then a space, and watch the change in the file. In the "default" view the ellipsis character is wider than the three dots, so it will get bigger; if you're in a fixed-width font, then you can see the three characters collapse into one.) You can hit command-shift-t (or choose Make Plain Text off the menu) if you want; but it won't revert that character back to three dots, nor will it stop changing three dots into a single character.

    Quote Originally Posted by bluej322 View Post
    Here's another question, how can i read the contents of an entire file? Do i have to go through line by line using fgets()?
    Most of the read functions will read a line at a time; if you want to do a binary read you can read arbitrary-sized chunks if you want, I suppose. Remember: you have to provide the memory for the file contents to be placed into (like you did with message) so that's what you'll want to have happen anyway.

  2. #17
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    Yes - you'll set up a WHILE or DO / WHILE or FOR loop.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM