My objective is to store the desired date and time.
In this case, I wish to stop reading when encounter the next blank line. Meaning I only wish to store the date and time - 20110129 18:47:01.
However, by using code below I will get the latest time stamp - 20110129 19:05:09 02.
Is there any better way to break from the while loop when encounter the blank line in between?
Sample file content:
Time_Stamp Value
20110129 18:21:12 01
20110129 18:40:59 02
20110129 18:47:01 02
20110129 18:59:06 02
20110129 19:05:09 02
Sample code:
See attached image for more info.Code:#include "stdafx.h"
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
char inLine[255]="", rDate[30]="", rTime[30]="";
FILE *fptr;
if(( fptr = fopen( "TimeStamp.txt", "r" )) != NULL )
{
fgets (inLine, 255, fptr);
while (!feof (fptr))
{
fgets (inLine, 255, fptr);
sscanf (inLine, "%s %s", rDate, rTime );
}
}
return 0;
}
Hope you all can advise.