Originally Posted by
Salem
So in other words, _TCHAR is declared as a wide character on your UNICODE enabled build.
Read your compiler documentation to see how you can cout a TCHAR (regardless of UNICODE mode).
I still have address issues with some parts of the code, note that this code is just me tooling around with reading files.
The main function is in rput_readfile, the line that prints addresses is:
Code:
cout << ar[0] << " " << ar[1] << " " << ar[2] << " " << ar[3] << " \n";
When switching from cout to wcout I get a crash when the program finishes.
Code:
void rput_readfile(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 count;
long total = 0;
char ch;
int spaces=0;
int newlines=0;
for (int file = 1; file < a; file++)
{
Begin = clock() * CLK_TCK;
fin.open(ar[file]);
count = 0;
fout.open("stupid");
while (fin.get(ch))
{
while(!fout.put(ch));
if (ch ==' ')
spaces++;
else if (ch == '\n')
newlines++;
count++;
}
cout << count << " characters in \n" ;
wcout << "Argument 1 : " << ar[1] << " \n";
total +=count;
fin.clear();
fin.close();
fout.close();
}
End = clock() * CLK_TCK;
cout << ar[0] << " " << ar[1] << " " << ar[2] << " " << ar[3] << " \n";
cout << total << " characters in all files\n";
elapTicks = End - Begin; //the number of ticks from Begin to End
elapMilli = elapTicks/1000; //milliseconds from Begin to End
elapSeconds = elapMilli/1000; //seconds from Begin to End
elapMinutes = elapSeconds/60; //minutes from Begin to End
if(elapSeconds < 1)
cout<<"\n\nIt took "<<elapMilli<<" milliseconds.";
else if(elapSeconds == 1)
cout<<"\n\nIt took 1 second.";
else if(elapSeconds > 1 && elapSeconds < 60)
cout<<"\n\nIt took "<<elapSeconds<<" seconds.";
else if(elapSeconds >= 60)
cout<<"\n\nIt took "<<elapMinutes<<" minutes.";
double meg_sec = 0;
double total1 = 0;
total1 = total / 1000000;
meg_sec = total1 / elapSeconds;
cout <<"\nMegs per second was " << meg_sec;
printf ("\nDecimals: %d %ld\n", meg_sec, total);
cout << "\nSpaces were: " << spaces << " Newlines were: " << newlines;
cout << "\n";
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc == 1)
{
wcout << "Usage : " << argv[0] << " filename[s]\n";
exit(1);
}
rput_readfile(argc, argv);
return 0;
}