프로그램이 파일을 읽고 파일에서 문자를 가져온 후 다른 파일을 읽으려는 경우 사용자에게 묻습니다. 사용자가 예라고 말하면 프로그램은 파일 이름을 묻습니다. 그러나 자동으로 파일을 열 수 없으며 루프를 종료합니다. 도와주세요. 여기 첫 번째 파일 이후에 C++ 후속 파일이 열리지 않음
코드입니다 :do //do while opening the source file fails
{
cout << "Enter filename of source file: ";
cin.getline (filename,51);
sourceFile.open(filename); //opens the file with given filename
if (sourceFile.fail())
cout << "File could not be opened" << endl; //error if can't open
sourceFile.clear();
}
while (sourceFile.fail()); //exits if source file doesn't fail
당신은 디버거를 시도 했습니까? 열려고 시도한 파일 이름이 의미가 있었습니까? –
좋은 디버거 란 무엇입니까? –
어떤 오류가 발생합니까? 어떤 시스템을 실행하고 있습니까? 'gdb'는 널리 사용되는 디버거이지만 사용하는 시스템은 사용중인 시스템에 따라 다릅니다. –