Write text file to char array

This is a discussion on Write text file to char array within the C Programming forums, part of the General Programming Boards category; Hey, Simple answer i'm sure, but can't seem to find a clear answer... How do you write a text file ...

  1. #1
    mjh
    mjh is offline
    Registered User
    Join Date
    Apr 2007
    Posts
    1

    Write text file to char array

    Hey,
    Simple answer i'm sure, but can't seem to find a clear answer...
    How do you write a text file to a character array in C?
    mjh

  2. #2
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    By simply reading its content into a char array using fgets(), just as explained here (urgh, that link is actually pretty bad), better explained here.

    You might also want to read the C string tutorial where an example with fgets() is given.
    Last edited by KONI; 04-02-2007 at 07:59 AM.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,450
    or strcpy and other function fro manipulating strings like sprintf
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  3. comparing fields in a text file
    By darfader in forum C Programming
    Replies: 9
    Last Post: 08-22-2003, 08:21 AM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

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