![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to read a specific value from a Log file? | cooolthud | Shell Programming and Scripting | 8 | 04-17-2008 11:30 AM |
| Post Shell programming: Question about source a file and read data from the file | ccwq | Shell Programming and Scripting | 3 | 08-04-2007 10:28 PM |
| read specific text from a log file | ragha81 | Shell Programming and Scripting | 4 | 10-17-2006 01:17 PM |
| How do you specific lines in a file? | hedgehog001 | UNIX for Dummies Questions & Answers | 2 | 08-23-2005 12:04 AM |
| Shell Script to read specific lines in a file | varshanswamy | Shell Programming and Scripting | 5 | 08-22-2005 07:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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:
Code:
#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;
}
|
|
||||
|
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 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|