Thread: need advice

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    6

    need advice

    Hello i need some advice here to write my program in c language.
    Let say my filename is : log.txt

    My file "log.txt" contains data like this:

    !!Begin
    Source bserver:bmp_spool:the, Job 80c481ac001f6b07, Inst 80c481ac001f6b07
    Title BP Page 003 Date 070402 Black 3
    Action Finished Transmit, Ok Date Fri Apr 5 00:02:05 SGT 2002
    (2) Source Queue = Ajil_Tabloid
    (1) Destination = ajil:ajil1:bmp_spool:the
    (3) Dest Queue = Futuro Tabloid
    Transmitting to ajil:ajil1:bmp_spool:the
    !!End
    !!Begin
    Source bserver:bmp_spool:the, Job 80c481ac001f6b0f, Inst 80c481ac001f6b0f
    Title BP Page 004 Date 070402 Cyan 4
    Action Started Transmit, Ok Date Fri Apr 5 00:02:05 SGT 2002
    (2) Source Queue = Ajil_Tabloid
    (1) Destination = ajil:ajil1:bmp_spool:the
    (3) Dest Queue = Futuro Tabloid
    Transmitting to ajil:ajil1:bmp_spool:the
    !!End
    !!Begin
    Source bserver:bmp_spool:the, Job 80c481ac001f6b3d, Inst 80c481ac001f6b63
    Title BP Page 010 Date 070402 Magenta 10
    Action Finished Transmit, Ok Date Fri Apr 5 00:02:12 SGT 2002
    (2) Source Queue = Prai_Tabloid
    (1) Destination = prairai1:bmp_spool:the
    (3) Dest Queue = Futuro Tabloid
    Transmitting to prairai1:bmp_spool:the
    !!End


    I need to write c program and process , give me output like this in output file:


    Title :BP Page 003 Date 070402 Black 3
    Action: Finished Transmit
    Time: 5 00:02:05
    Misc: (3) Dest Queue = Futuro Tabloid

    Title :BP Page 004 Date 070402 Cyan 4
    Action: Started Transmit
    Time: 5 00:02:05
    Misc: (3) Dest Queue = Futuro Tabloid

    Title:Title BP Page 010 Date 070402 Magenta 10
    Action :Finished Transmit
    Time: 5 00:02:12
    Misc3) Dest Queue = Futuro Tabloid


    Thank you. Any sample with sourcecode are appreciate.
    sorry my english language not good.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Read the file, use strcmp() to check for the values you want, and output them in the format you want.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    The file looks like it is formatted in a logical manner. You can simply write a program to test your input and only take what you want. Or assume that the file is formatted correctly and use that formatting to parse each line. Such as with getline and sscanf:

    Input:
    Action Finished Transmit, Ok Date Fri Apr 5 00:02:05 SGT 2002

    Code:
    getline ( INFILE, buffer );
    sscanf ( buffer, "%*s %[^,] %*[^0123456789] %10c", actionString, timeString );
    cout<< actionString <<"\n"<< timeString <<"\n";

    Output:
    Finished Transmit
    5 00:02:05


    -Prelude
    My best code is written with the delete key.

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. Advice on multithreading
    By Calef13 in forum C++ Programming
    Replies: 3
    Last Post: 08-24-2007, 03:28 PM
  3. 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
  4. need advice on project
    By lambs4 in forum C Programming
    Replies: 2
    Last Post: 07-23-2003, 01:06 PM
  5. Who's telling the truth??? Career Advice Needed Badly
    By Ican'tCjax,fl in forum C Programming
    Replies: 1
    Last Post: 11-06-2002, 06:16 PM