Thread: How to Read Text file in C !!

  1. #1
    Unregistered
    Guest

    Question How to Read Text file in C !!

    Hello,
    I want a function in C that will read line by line from text file and that function should compare line by line .
    If next line is different from previous line , i want to display the line number of text where i found the difference !!

    I will appreciate if any one gives this function in C .

    Regards,
    Hari

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Use fgets and 2 large character arrays if you want to process a whole line at a time. For each loop cycle/line increment a counter variable. Use strcmp standard library function to compare the previous line to the current line.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  2. [HELP] Read text file in vc++ 2005
    By sonnb in forum C++ Programming
    Replies: 1
    Last Post: 05-12-2007, 10:01 AM
  3. How to read chars from a text file and use them in TChart
    By Bachatero in forum C++ Programming
    Replies: 1
    Last Post: 08-29-2006, 04:03 PM
  4. getline function to read 1 line from a text file
    By kes103 in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:21 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