I am working on an example for a class and the build succeeds, but when it runs, it just hangs and won't complete. Not sure what I'm doing wrong?
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[]) {
istream *fin = &cin;
if(argc > 1)
{
ifstream infile(argv[1], ios::in);
if (!infile) return 1;
fin = &infile;
}
while (1)
{
char c;
fin->get(c);
if (! *fin) break;
cout.put(c);
}
return 0;
}