S
srikanth
i have a text file like below,
test.txt file (actually my test file file is with 10000 lines but here
i tested with 3 lines)
3 06.09.2006 16:37:25
3 06.09.2006 16:40:02
3 06.09.2006 16:42:31
i want to read this and output as it looks but iam getting abnormal
results like this and i used fscanf in my code,
RESULT:
num: 3 date: .09.2006
time:16:37:2516:40:0216:42:31
num: 3 date: 06.09.200606.09.2006 time:16:40:0216:42:31
num: 3 date: 06.09.2006 time:16:42:31
my code is
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
char testDatestr[3][10];
char testTimeStr[3][8];
fp = fopen( "test.txt", "r");
while(fgetc(fp) != EOF)
{
fscanf(fp, "%d %s
%s",&SeriNumber,&testDatestr[0],&testTimeStr[0]);
i++;
}
fclose(fp);
for(j = 0; j<3; j++)
printf("\n num: %d date: %s
time:%s",SeriNumber,testDatestr[j],testTimeStr[j] );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
could anyone can please suggest me how can i read numbers and strings
of a file and output as it is.
Thanks alot,
Regards,
Srikanth
test.txt file (actually my test file file is with 10000 lines but here
i tested with 3 lines)
3 06.09.2006 16:37:25
3 06.09.2006 16:40:02
3 06.09.2006 16:42:31
i want to read this and output as it looks but iam getting abnormal
results like this and i used fscanf in my code,
RESULT:
num: 3 date: .09.2006
time:16:37:2516:40:0216:42:31
num: 3 date: 06.09.200606.09.2006 time:16:40:0216:42:31
num: 3 date: 06.09.2006 time:16:42:31
my code is
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
char testDatestr[3][10];
char testTimeStr[3][8];
fp = fopen( "test.txt", "r");
while(fgetc(fp) != EOF)
{
fscanf(fp, "%d %s
%s",&SeriNumber,&testDatestr[0],&testTimeStr[0]);
i++;
}
fclose(fp);
for(j = 0; j<3; j++)
printf("\n num: %d date: %s
time:%s",SeriNumber,testDatestr[j],testTimeStr[j] );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
could anyone can please suggest me how can i read numbers and strings
of a file and output as it is.
Thanks alot,
Regards,
Srikanth