Hi everyone!
Using Linux with NFS, I run this program and it crashes when trying to open the file "grafo4.grf", a file that exists. The real code is different, I just left the parts where errors occur.
Could anyone give me a pointer to a solution at least?
As always, thanks all replys!
Here is the code:
Code:#include <iostream> #include <fstream> using namespace std; int main(){ char file_name[10]; ifstream input; int fileNumber = 0; bool done = false; cout << "Check 1 " << endl; while(!done){ sprintf(file_name, "%s%d%s", "grafo", fileNumber, ".grf"); input.open(file_name); if(!input) done = true; else fileNumber++; input.close(); } cout << "Check 2 " << endl; /* abre o arquivo correto */ sprintf(file_name, "grafo%d.grf",--fileNumber); input.open(file_name); if(!input){ cerr << "Error opening file " << file_name << endl; return 1; } input.close(); cout << "Check 3 " << endl; for(int i=0;i<=fileNumber;i++){ sprintf(file_name, "grafo%d.grf", i); input.open(file_name); if( !input ){ cerr << "Error opening file " << file_name << endl; return 1; } input.close(); } cout << "Check 4 " << endl; input.open("corte.crt"); if(!input){ cerr << "Error opening file " << file_name << endl; return 1; } input.close(); cout << "Ok =D" << endl; return 0; }



LinkBack URL
About LinkBacks


