need advice again

This is a discussion on need advice again within the C Programming forums, part of the General Programming Boards category; Need advice here. i have input file that contains data as shown below. My program read this data line by ...

  1. #1
    roslinst
    Guest

    Question need advice again

    Need advice here. i have input file that contains data as shown below.
    My program read this data line by line. when it encounter "(3)"
    i want my program to output it as show below in my output file.
    any suggestion command,syntax i must use.


    /* my input file*/
    asdfjkljkasdl;f
    asfklasdfj
    Page 028 Date 291002 Black 28 23:55:31
    (2)
    (1)
    (3)
    ldfjasdklfjas
    dfklasdfj;asldf
    Date 291002 Black 28 Started Transmit, 23:55:40
    (2)
    (1)
    (3)
    asdkl;fjasdlf
    asfklasdfjas
    dafksladfj


    /* output file*/

    Page 028 Date 291002 Black 28 23:55:31
    Date 291002 Black 28 Started Transmit, 23:55:40

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Linked lists are your friend. If you don't know how to make one, use the handy dandy search function here, or go to google and search there.

    To save you the head ache, use a double linked list, it'll be a breeze.

    Create a linked list where each node contains a single line. When you are done, you go through your list, or as you're creating, whatever, go back three places, and print that node's data.

    Here's the structure to get you started:
    Code:
    struct node {
        struct node *prev, *next;
        char * data;
    };
    Read a single line of text from your file, get it's length, malloc that size plus one for the 'data' field, copy it there, continue on your merry way. Hint: fgets() is your friend.

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

  3. #3
    roslinst
    Guest

    Smile need advice again2

    quzah can u give me example program?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice on C Programming with MSVC++ 2008
    By IT_Guy in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2009, 04:23 AM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  3. Resume advice
    By Zughiaq in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-15-2005, 03:16 PM
  4. girl friend advice (prob. the wrong place)
    By B0bDole in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2004, 07:38 PM
  5. Partitioning advice?
    By mart_man00 in forum Tech Board
    Replies: 6
    Last Post: 01-10-2003, 10:53 PM

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