File Line Re-arranging program

Discussion in 'C' started by Frusciante, Jul 4, 2007.

  1. Frusciante

    Frusciante New Member

    Joined:
    Jul 4, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi!
    I'm writing a small C program to post process a huge txt file produced by a CFD software.

    The CFD creates a "from.txt" file, in which every line contains many parameters calculated by it.
    I need to copy the lines that contain the information i need to another "to.txt" files.

    The problem is that I donĀ“t know how to go thru the lines of the from.txt.
    Once i know how to go thru them it wouldn't be that hard to write the rest of the program.

    I working on something like...

    fp=fopen(filename,"r");
    while(c == getchar());
    if (c == \n);

    ... but i have no idea how to go on...

    I`m a newbie in this world... hope learn a lot from you all!
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
    c == getchar() will go through the content of the file character by character.
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Look up fgets.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice