두 개의 개별 파일의 첫 번째 줄을 읽고이를 비교하려면 ... 다음 코드는 사용하지만 "문자열 오류에 대한 istream"을 제공합니다. while 조건을 사용하여 파일을 먼저 읽어야합니까?getline 및 파일 처리
ifstream data_real(filename.c_str()); /*input streams to check if the flight info
are the same*/
ifstream data_test("output_check.txt");
string read1, read2;
string first_line_input = getline(is,read1);
string first_line_output_test = getline(data_test,read2);
string test_string1, test_string2;
int num_lines_output_test, num_lines_input;
if((first_line_input.substr(0,3)==first_line_output_test.substr(0,3)))
{
while(!data_test.eof()) // count the number of lines for the output test file with the first flight info
{
getline(data_test,test_string1);
num_lines_output_test++;
}
while(getline(is,test_string2)) // count the number of lines for the output test file with the first flight info
{
if(test_string2.substr(0,3)!="ACM")
num_lines_input++;
else
break;
}
}
실제 오류 메시지를 복사하여 붙여 넣으십시오. –