Hi guys.
Can you please tell me why this code prints garbage and loops forever.
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main (int agrc, char* argv[])
{
fstream file;
fstream output;
wchar_t *c1;
if (argv[1] == NULL)
{
cout << "Usage: Profiler <file-name.c>" << endl;
exit (1);
}
file.open ("c:\258_assignment2\Profiling\ff.c", ios::in);
output.open ("output", ios::out);
while (!file.eof() )
{
char c;
c = file.get();
cout << c << endl;
output << c << endl;
}
return 0;
}
I also have two questions:
1- how can i check if the file opened successfully?
2- i need to pass the argv[1] to open as filename, but i get an error about wchar_t type. I ca't seems to pass char*. How can i solve this?
Thanks!