Hi,
I'm trying to delete a line in a file, but I'm not succeeding very well... Here is my function:
I get an error on contents = sprintf... Do you see any directly errors or shell I show my error messages too?Code:void deleteLine( int id ) { string contents; int i = 1; ifstream file ( "file.txt" ); while ( file.good() ) { if ( i != id ) { contents = sprintf("%s%s", contents, file.getline() ); } i++; } file.close(); ofstream file ( "file.txt" ); file << contents; file.close(); }
Yours, @nders.