[C++] Obsługa plików. Getline
Ostatnio zmodyfikowano 2015-12-29 17:37
yanaz_pl Temat założony przez niniejszego użytkownika |
[C++] Obsługa plików. Getline » 2015-12-29 17:37:19 Po uruchomieniu dla nazwy pliku text.txt - pliku w tym samym folderze co .exe daje debug error abort() has been called #include "..\..\std_lib_facilities.h" void get_input( vector < string > & sv ); int main() { vector < string > sv; get_input( sv ); return 0; }
void get_input( vector < string > & sv ) { sv.clear(); cout << "Name file to open: "; string name; cin >> name; ifstream ifs { name }; if( !ifs ) error( "couldn't open the file" ); while( !ifs.fail() ) { string line; getline( ifs, line ); sv.push_back( line ); } if( ifs.bad() ) error( "input file stream bad" ); } |
|
« 1 » |