Thread: Reading lines from a file and saving to a variable

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    Reading lines from a file and saving to a variable

    hi is there any one who would be kind enough to tell me the function or even an example :P
    on how to read lines and and so on from a file and save to a char say like

    ##1234
    ##4321
    ##abcd

    and it reads say 3 from the first line.
    1 from the second line and a from the first line
    thanks

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    FAQ. Replace stdin with the file pointer for your file. Look up the functions fopen and fclose for opening and closing files.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Saving Variable File Name
    By Apocalyptic_end in forum C++ Programming
    Replies: 9
    Last Post: 01-27-2008, 09:46 AM
  3. Replies: 2
    Last Post: 06-16-2005, 10:03 AM
  4. saving screen to file
    By z0diac in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-23-2003, 07:00 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