reading text file

This is a discussion on reading text file within the C Programming forums, part of the General Programming Boards category; I have this text file and I need to read it in and copy it to memory, but I am ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    2

    reading text file

    I have this text file and I need to read it in and copy it to memory, but I am not exactly sure how to do it. Could someone please help me?

    Code:
     
    Block 0
       #Stuff = 0x0
       #Comments for Block 0
       0033FFEEDDCCBBAA
       95D3C7F0E9343A13
       238D9A0CE94B3457
    EOB 0
    Block 1
       #Stuff = 0x1
       #Comments for Block 1
       0033FFEEDDCCBBAA
       39D347F50B347645
       065F6EDE94B04457
    EOB 1
    I know how to open the file and check to see if it opened properly, but I don't know what to do after setting up the buffer.

    Code:
     
    unsigned char *buffer;
    
    buffer = (char *)malloc(size_of_file);
    
    if (buffer == NULL) 
       // Error
    
    // now what????
    
    free(buffer); 
    fclose(dFile);
    Last edited by haw6434; 05-16-2003 at 03:17 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    How about taking two minutes to read the next chapter in your book where they tell you how to read from a file? I mean seriously, you learned about fopen some place. Turn the page and read about fread/fwrite/fgetc/fputc/a ton of other functions related to file manipulation.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    2

    Thank you...

    Salem...

    I really appreciate your help!

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Reading Character at a time from a text file
    By Giania in forum C Programming
    Replies: 8
    Last Post: 02-25-2006, 02:17 PM
  5. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 01:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21