How to read specific lines in a bulk file using C file Programming

Please Help me

I have a Bulk file containing Hex data
I want to read specific lines from that bulk file by ID number.

example
ID DATE Time data
14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223 04B089 06AE50 000000 000000 000000

14 2005/09/28 07:42:27.765 0 5 078B1C 01916C 0A605E 08008A 04B85C 0D06D2 05B760 083222 045489 0CB190 000000 000000 000000

14 2005/09/28 07:44:41.274 0 5 078B1C 01916C 0FB19E 004B54 0A96AB 0D04ED 05B6B4 0E2223 04B089 06AE50 000000 000000 000000

suppose from that bulk file I want to read above Id 14 how it is possible.
by using c file programming.

please provide me code.

thanks
rajan

Hi Rajan,

Where is the difficulty you are facing?
Is the bulk nature of file bogging you or is it only two days for weekend to come :smiley:

rishi

You always have to read the whole file to find all records. This (minus error checking) is how to do it, by writing a simple filter:

#include <stdio.h>
void process_data(char *src)
{
     fprintf(stdout,"%s", src); /* do stuff with the data*/
}

int main()
{
    char tmp[256]={0x0};
    FILE *in=fopen"myfile","r");
    while(fgets(tmp,sizeof(tmp),in)!=NULL)
    {
         int testvalue=atoi(tmp);  /* atoi stops translating to an int
                                              when it hits a blank */
         if(test==14) process_data(tmp);
    }
    fclose(in);
    return 0;
}

you can use "cspilt" shell command to do that

Dear Friends,

The code you have given for Extractiong required data from file is working fine.
Thank u for your reply.
I have Extracted this data from file by using this code.

15711 2005/10/03 08:28:25.512 0 1 0B160E 06C67E 0A7F80 04C000 000000 000000 000000 000000 000000 000000 000000 000000 000000

  15711  2005/10/03  08:29:57.517  0  1 0BE202 08C37E 007380 04A000 000000 000000 000000 000000 000000 000000 000000 000000 000000

  15711  2005/10/03  08:31:29.502  0  1 0B9806 09C4DE 097800 048000 000000 000000 000000 000000 000000 000000 000000 000000 000000

  15711  2005/10/03  08:33:01.507  0  1 0BDC0A 0BC5FE 0E7D00 04C000 000000 000000 000000 000000 000000 000000 000000 000000 000000

Now I wanted to write only the Hexadecimal data in separate file like this.

0B160E 06C67E 0A7F80 04C000 000000 000000 000000 000000 000000 000000 000000 000000 000000

from the above data simultaniously I have to leave starting 0 digit in each filed.and write into a separate file.

please provide C code for me

Iam ever thankful to you

regards

rajan

Please read our rules and note:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

I will delete the thread where you post a second copy of this follow-up question.

anybody please send reply to my post.

awiting for your replies

thank u

regards
rajan

A post like that is a "bump up". Do not violate our rules again.

Dear friends

anybody please give reply to my above post.

regards
rajan

Please give reply anybody to the above post

please provide some code to the above post.

I can't get it.

regards
rajan