R
rsk
Hi Friends,
I have written a code which suppose to read all the numbers from a hex
file,But to my surprise the code is skiping every alternate value.Don't
know why?
Can you please help me in solving this problem.
The code is as follows;
main ()
{
FILE *fdataptr;
int x;
int ctrl;
x=1;
// Open the file containing data
fdataptr = fopen("data.txt", "r");
if(fdataptr==NULL){
printf("\n Cannot open File data.txt");
exit(1);
}
do {
fscanf(fdataptr,"%x", &ctrl);
printf ("\n\n data is 0x%x \n\n",ctrl);
if (fscanf(fdataptr,"%x", &ctrl)==EOF)
break;
} while (x);
}
data.txt is having the values
11111111
22222222
33333333
44444444
55555555
66666666
77777777
88888888
99999999
Thanks & Regards,
RSK...
I have written a code which suppose to read all the numbers from a hex
file,But to my surprise the code is skiping every alternate value.Don't
know why?
Can you please help me in solving this problem.
The code is as follows;
main ()
{
FILE *fdataptr;
int x;
int ctrl;
x=1;
// Open the file containing data
fdataptr = fopen("data.txt", "r");
if(fdataptr==NULL){
printf("\n Cannot open File data.txt");
exit(1);
}
do {
fscanf(fdataptr,"%x", &ctrl);
printf ("\n\n data is 0x%x \n\n",ctrl);
if (fscanf(fdataptr,"%x", &ctrl)==EOF)
break;
} while (x);
}
data.txt is having the values
11111111
22222222
33333333
44444444
55555555
66666666
77777777
88888888
99999999
Thanks & Regards,
RSK...