meghadaga
Newbie level 1
Hi Everyone,
I am trying to read an external txt file in C5416. I have provided proper header file; stdio.h. But somehow the file is not getting opened. I am reading it as follows:
if((fileid = fopen( "test", "r" )) == NULL )
printf( "The file 'test' was not opened\n" );
else
printf( "The file 'test' was opened\n" );
while(1)
{
if(fgets(temp, 250, fileid) == NULL)
{
exit(1);
}
sscanf(temp, "%s", &temp);
if(!strcmp(temp,"NUMCHAN"))
{
fgets(temp, 250, fileid);
sscanf(temp, "%hu", &numchan);
break;
}
}
While running the program displays the file test was not opened. I dont know why this is happening. If someone has ever read data from a file in C5416, Kindly help me out.
Waiting for reply
Thanking You
Megha Daga
I am trying to read an external txt file in C5416. I have provided proper header file; stdio.h. But somehow the file is not getting opened. I am reading it as follows:
if((fileid = fopen( "test", "r" )) == NULL )
printf( "The file 'test' was not opened\n" );
else
printf( "The file 'test' was opened\n" );
while(1)
{
if(fgets(temp, 250, fileid) == NULL)
{
exit(1);
}
sscanf(temp, "%s", &temp);
if(!strcmp(temp,"NUMCHAN"))
{
fgets(temp, 250, fileid);
sscanf(temp, "%hu", &numchan);
break;
}
}
While running the program displays the file test was not opened. I dont know why this is happening. If someone has ever read data from a file in C5416, Kindly help me out.
Waiting for reply
Thanking You
Megha Daga