C++文件读取小问题!!!
int main(){
string test="test.txt";
ifstream in(test,ifstream::in);
if(!in){
cout<<"wrong"<<endl;
return -1;
}
vector<string> v;
string line;
while(getline(in,line)){
cout<<line<<endl;
}
return 0;
}
while(getline(in,line)){
cout<<line<<endl;
}
while里面怎么实现的一行一行的读取数据?getline不是遇到回车就结束了吗 那不是第一行读取完了while就结束了,那是怎么读取每一行数据的呢?