Thread: 2 File Related Questions

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    266

    2 File Related Questions

    1)What is the best way to read in the entire file and put it in one string? Most functions stop at an \n or a white space and I REALLY don't want to go line by line.

    2)What is the best way to find the size of the file(might be beyond C standard library)?
    Fried chicken for everybody!
    -Kernel Sanders

  2. #2
    Registered User
    Join Date
    Dec 2008
    Posts
    7
    i could answer and give you a nice code to work with, but ive read the "read me first" and you should come up with your own effort first ?

    if im wrong, tell me and i'll give you a code to work with

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Can you give us an example of what your problem is? Do you have EOF char's inside the file you want to copy? Are you running out of space in your string's memory?

    In programming, please remember:

    Answering general questions with general answers, is generally useless.

    Eastmus - props on your restraint, bro!
    Last edited by Adak; 12-31-2008 at 07:50 AM.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> but ive read the "read me first"
    Nice! Welcome to the boards!

    1) fread
    2) fseek/ftell - however, you'll have to open the file in binary - which means that you won't get \r\n->\n conversions done for you under Windows.

    gg

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Sorry. I did have an effort I just didn't think it was relevant because I thought I was doing it wrong. Thanks for the help.
    Fried chicken for everybody!
    -Kernel Sanders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM