Thread: nee advice

  1. #1
    loka
    Guest

    Question nee advice

    i have file contains this data:

    29BH45C1 Black 1 AtomicDelete, Ok D 23:55:31
    29ns21b3.qxd 1 Finished Transmit, 23:55:31
    MM Page 028 Date 291002 Black 28 Started Transmit, 23:55:31
    (2)
    (1)
    (3)
    29NT01B1.QXD Magenta 1 AtomicDelete, Ok D 23:55:39
    29ns21b3.qxd 1 Finished Transmit, 23:55:39
    29NT15N1.QXD 1 AtomicDelete, Ok D 23:55:40
    29ns21b3.qxd 1 Finished Transmit, 23:55:40
    29ns21b2.qxd 1 AtomicDelete, Ok D 23:55:46
    29ns21b3.qxd 1 Finished Transmit, 23:55:46
    MM Page 028 Date 291002 Black 28 Finished Transmit, 23:56:07
    (2)
    (1)
    (3)

    i need output like this:
    MM Page 028 Date 291002 Black 28 Started Transmit, 23:55:31
    MM Page 028 Date 291002 Black 28 Started Transmit, 23:55:31

    need any suggestion of command,syntax
    it meant when my program file read (3) it turn back 3 steps backward and print output as i mention above

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm slightly confused here. Are you asking how to format the output of your program? Or are you asking now to read in the file that was described at the beginning of your post and output it as you described in part two of your post?

    If the second thing I said then what you could do is make your program pick up on keywords. You would of course tokenize the input file stream (strtok would do) compare it to a table of keywords (such as "transmit" and "started") then do your formatting.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I also am unsure of exactly what they need. It seems like they just want to print all of the lines with 'MM' at the start. If this is the case, the fix is easy:
    Code:
    fgets( buf, BUFSIZ, fp );
    if( buf[0] == 'M' && buf[1] == 'M' )
        fputs( buf, stdout );
    Otherwise you ignore the line.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need advice about list of lists
    By handytxg in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2009, 05:03 PM
  2. Advice on C Programming with MSVC++ 2008
    By IT_Guy in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2009, 04:23 AM
  3. Semaphores, need advice on implementation.
    By Swerve in forum C++ Programming
    Replies: 2
    Last Post: 01-13-2009, 01:54 AM
  4. Resume advice
    By Zughiaq in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-15-2005, 02:16 PM
  5. girl friend advice (prob. the wrong place)
    By B0bDole in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2004, 06:38 PM