| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ofstream.write problems
hello,
I need to write to a txt file, line by line. i have: PHP Code:
this will write the line, but not put a newline char at the end, so subsequently, when the code runs again, the next line appears on the same as the one before. any ideas? |
|
#2
|
|||
|
|||
|
Code:
dnffile.write(strMsgOut, strMsgOut.GetLength()); //does this work? what is this GetLength function? dnffile << endl; //add newline and flush the output buffer |
|
#3
|
|||
|
|||
|
GetLength() returns an int value of the length of the string, its a member of CString.
the << doesnt work in VC++, i get errors claiming that there is no appropriate conversion. |
|
#4
|
|||
|
|||
|
all right, here's another method:
I don't know how CStrings work (not using VC++ myself), but add a newline character on to the end. (probably something like strMsgOut += '\n'). \n is the newline character. Alternatively, if you can't modify strMsgOut, then put Code:
dnffile.write('\n', 1);
|
|
#5
|
|||
|
|||
|
Quote:
thanks that worked |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Ofstream.write problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|