S
Sea Squid
I am using Dev-C++ 4.9.8. The console stop after executing "cout << "Written
one iteration" << endl;".
Instructions in "if (! myFile){}" test is not run.
Thanks.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int i;
char c;
ofstream myFile("LPT1:");
// ofstream myFile("c:/out.txt");
// Creates an ofstream object named myFile
if (! myFile) // Always test file open
{
cout << "Error opening output file" << endl;
return -1;
}
for(i = 0; i < 5; i++) {
// c = getc();
c = 1;
cout << "Written one iteration" << endl;
myFile << c << endl;
}
myFile.close();
return 0;
}
one iteration" << endl;".
Instructions in "if (! myFile){}" test is not run.
Thanks.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int i;
char c;
ofstream myFile("LPT1:");
// ofstream myFile("c:/out.txt");
// Creates an ofstream object named myFile
if (! myFile) // Always test file open
{
cout << "Error opening output file" << endl;
return -1;
}
for(i = 0; i < 5; i++) {
// c = getc();
c = 1;
cout << "Written one iteration" << endl;
myFile << c << endl;
}
myFile.close();
return 0;
}