The code does not display the output from the beginning with timestamp function
<p>I used the following code in order to read multiple .dat files using Dev C++ 5.4.1, The purpose is to find the reading time. However, I'm trying to display the content of these file, the problem is displaying data (which are records of text data) does not start from the beginning, for example if the file (in case one file) contains 60 records it displays the last 20 records. Now if there is multiple files, the output might skip the first file or first two files and print the rest of the files. I think there is something should be modified with the Dev C++, otherwise my timestamp function is not correct. Noteworthy, when I debug line by line, it works very well and displays from the beginning! </p>

<pre><code>#include &lt;Windows.h&gt;
#include &lt;ctime&gt;
#include &lt;stdint.h&gt;
#include &lt;iostream&gt;
using std::cout;
using std::endl;
#include &lt;fstream&gt;
using std::ifstream;

#include &lt;cstring&gt;

/* Returns the amount of milliseconds elapsed since the UNIX epoch. Works on both
 * windows and linux. */

uint64_t GetTimeMs64()
{


 FILETIME ft;
 LARGE_INTEGER li;

 /* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and copy it
  * to a LARGE_INTEGER structure. */
 GetSystemTimeAsFileTime(&amp;ft);
 li.LowPart = ft.dwLowDateTime;
 li.HighPart = ft.dwHighDateTime;

 uint64_t ret;
 ret = li.QuadPart;
 ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */
 ret /= 10000; /* From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals */

 return ret;

}


const int MAX_CHARS_PER_LINE = 512;
const int MAX_TOKENS_PER_LINE = 20;
const char* const DELIMITER = "|";

int main()
{
  // create a file-reading object
  uint64_t a = GetTimeMs64();
  cout &lt;&lt; a &lt;&lt; endl;
  HANDLE h;
WIN32_FIND_DATA find_data;
h = FindFirstFile( "*.dat", &amp; find_data );
if( h == INVALID_HANDLE_VALUE ) {
    cout&lt;&lt;"error"&lt;&lt;endl;

}
do {
    char * s = find_data.cFileName;

    ifstream fin;
  fin.open(s); // open a file
  if (!fin.good()) 
    return 1; // exit if file not found

  // read each line of the file
  while (!fin.eof())
  {
    // read an entire line into memory
    char buf[MAX_CHARS_PER_LINE];
    fin.getline(buf, MAX_CHARS_PER_LINE);

    // parse the line into blank-delimited tokens
    int n = 0; // a for-loop index

    // array to store memory addresses of the tokens in buf
    const char* token[MAX_TOKENS_PER_LINE] = {}; // initialize to 0

    // parse the line
    token[0] = strtok(buf, DELIMITER); // first token
    if (token[0]) // zero if line is blank
    {
      for (n = 1; n &lt; MAX_TOKENS_PER_LINE; n++)
      {
    token[n] = strtok(0, DELIMITER); // subsequent tokens
        if (!token[n]) break; // no more tokens
  }
}

    // process (print) the tokens
    for (int i = 0; i &lt; n; i++) // n = #of tokens
      cout &lt;&lt; "Token[" &lt;&lt; i &lt;&lt; "] = " &lt;&lt; token[i] &lt;&lt; endl;
    cout &lt;&lt; endl;
  }
            // Your code here
} while( FindNextFile( h, &amp; find_data ) );
FindClose( h );



  uint64_t b = GetTimeMs64();
  cout &lt;&lt; a &lt;&lt; endl;
  cout &lt;&lt; b &lt;&lt; endl;
  uint64_t c = b - a;
  cout &lt;&lt; c &lt;&lt; endl;

  system("pause");
}
</code></pre>
