S
skumar434
my problem , Its some
thing like there is a file (text file) which contains the details of
the system ,like the its unique serial no which is homid and etc.
This code is working only for fetching the stating data .
#include <stdio.h>
#include <string.h>
#include <unistd.h>
struct hom_id{
char nod_de[20];
char hom_id[20];
char hom_type[20];
char hom_pid[20];
};
#define LENTH 4
int main ()
{
FILE *fp;
char buff[200];
int ret;
int read_size;
struct hom_id arr[LENTH];
int i=0;
char* poc_id = "0086";
fp = fopen("momtext.txt","r");
if ( fp == NULL )
{
printf("error");
}
sscanf ( buff , " %s %s %s %s ", &arr.nod_de ,
&arr.hom_id ,&arr.hom_type,&arr.hom_pid );
fgets ( buff, 100,fp);
printf("the hom id\t %s \t %s \t %s \t %s \n ",arr.nod_de,
arr.hom_id, arr.hom_type, arr.hom_pid );
//}
}
->I am faceing one error for this 0086 , I am getting radix error.
-> Can you tell me how to moove in side a file , I need it because
the text file from which I have to fetch data is like this --
00810000 00814945 00c9 0000d005
00810000 00814946 00c9 0000d006
00810000 00814947 00c9 0000d007
00810000 00814948 00c9 0000d008
00810000 00814949 00c9 0000d009
00810000 0081494a 00c9 0000d00a
00810000 0081494b 00c9 0000d00b
00810000 00814960 00c9 0000d00c
00810000 00814961 00c9 0000d00d
00810000 00814962 00c9 0000d00e
00810000 00814963 00c9 0000d00f
00810000 00814964 00c9 0000d010
00810000 00814965 00c9 0000d011
00810000 00814966 00c9 0000d012
00810000 00814967 00c9 0000d013
00810000 00814968 00c9 0000d014
00810000 00814969 00c9 0000d015
00810000 0081496a 00c9 0000d016
00810000 0081496b 00c9 0000d017
00810000 00815000 0044 ffffffff
00810000 00815002 0044 ffffffff
00810000 00815080 0044 ffffffff
00810000 008150c0 0044 ffffffff
00810000 008150c2 0044 ffffffff
00810000 00815180 0044 ffffffff
00810000 008151e0 0044 ffffffff
00810000 008151e1 0044 ffffffff
00810000 00815280 0044 ffffffff
-> I have to write a function which will take this 008151e1 as argument
(which is second column in above).
-. So for that i have to search the pattern and copy the lines which
contains the uniqe id 008151e1 to a structure .
-> how can I moove inside a file so that I can searech the pattern.
->waht data type i should use to store 008151e1 this type of variable.
-.plz help me .
thing like there is a file (text file) which contains the details of
the system ,like the its unique serial no which is homid and etc.
This code is working only for fetching the stating data .
#include <stdio.h>
#include <string.h>
#include <unistd.h>
struct hom_id{
char nod_de[20];
char hom_id[20];
char hom_type[20];
char hom_pid[20];
};
#define LENTH 4
int main ()
{
FILE *fp;
char buff[200];
int ret;
int read_size;
struct hom_id arr[LENTH];
int i=0;
char* poc_id = "0086";
fp = fopen("momtext.txt","r");
if ( fp == NULL )
{
printf("error");
}
sscanf ( buff , " %s %s %s %s ", &arr.nod_de ,
&arr.hom_id ,&arr.hom_type,&arr.hom_pid );
fgets ( buff, 100,fp);
printf("the hom id\t %s \t %s \t %s \t %s \n ",arr.nod_de,
arr.hom_id, arr.hom_type, arr.hom_pid );
//}
}
->I am faceing one error for this 0086 , I am getting radix error.
-> Can you tell me how to moove in side a file , I need it because
the text file from which I have to fetch data is like this --
00810000 00814945 00c9 0000d005
00810000 00814946 00c9 0000d006
00810000 00814947 00c9 0000d007
00810000 00814948 00c9 0000d008
00810000 00814949 00c9 0000d009
00810000 0081494a 00c9 0000d00a
00810000 0081494b 00c9 0000d00b
00810000 00814960 00c9 0000d00c
00810000 00814961 00c9 0000d00d
00810000 00814962 00c9 0000d00e
00810000 00814963 00c9 0000d00f
00810000 00814964 00c9 0000d010
00810000 00814965 00c9 0000d011
00810000 00814966 00c9 0000d012
00810000 00814967 00c9 0000d013
00810000 00814968 00c9 0000d014
00810000 00814969 00c9 0000d015
00810000 0081496a 00c9 0000d016
00810000 0081496b 00c9 0000d017
00810000 00815000 0044 ffffffff
00810000 00815002 0044 ffffffff
00810000 00815080 0044 ffffffff
00810000 008150c0 0044 ffffffff
00810000 008150c2 0044 ffffffff
00810000 00815180 0044 ffffffff
00810000 008151e0 0044 ffffffff
00810000 008151e1 0044 ffffffff
00810000 00815280 0044 ffffffff
-> I have to write a function which will take this 008151e1 as argument
(which is second column in above).
-. So for that i have to search the pattern and copy the lines which
contains the uniqe id 008151e1 to a structure .
-> how can I moove inside a file so that I can searech the pattern.
->waht data type i should use to store 008151e1 this type of variable.
-.plz help me .