I've been noticing the gap between characters read and the file size on my XP system with a loop I just have go through a text file and read characters.
Is EOF OS/Implementation specific? So far from what I calculated from the input filesize is 1210, the # of characters is 1188 which leaves 22 bytes unaccounted for. Here's the code
Code:
void rput_readfilev2(int a, _TCHAR * ar[])
{
int elapTicks;
double elapMilli, elapSeconds, elapMinutes;
clock_t Begin, End; //initialize Begin and End for the timer
/*
Begin = clock() * CLK_TCK; //start the timer
for(int a=1; a<=10000; a++);
End = clock() * CLK_TCK; //stop the timer
*/
ifstream fin;
ofstream fout;
long count2 =0;
long count;
long total = 0;
int ch;
int spaces=0;
int newlines=0;
int style =0;
// fout.open(ar[2]); Open filename2(argument #2) for output
int file = 1;
Begin = clock() * CLK_TCK;
fin.open(ar[file]);
count = 0;
cout << file << " \n";
ch = fin.get();
while ( ch != EOF) // While ch does not equal end of file, while quites if ch is EOF (end of file)
{
ch = fin.get();
/*cout << " 1. m " << count << "\n";*/
if (ch ==' ')
spaces++;
else if (ch == '\n')
newlines++;
cout << ch << " \n";
count++;
}
cout << "\n";
cout << "\nThere was " << count << " characters in \n" ;
wcout << "Argument 1 : " << ar[1] << " \n";
total +=count;
fin.clear();
fin.close();
// fout.close(); Closing the output file