CC> @MSGID: 1:3811/350 770b0538
CC> The following pseudo-code has an unfortunate side effect:
CC> (using Borland c++ 4.51)
CC> ofstream outf("out.bin");
CC> char string[6];
CC> strcpy(string,"12345");
CC> string[strlen(string)] = '\n';
CC> outf.write(string, strlen(string));
CC> outf.close();
CC> 12345#13#10 (where #13 & #10 are ascii characters)
CC> What the hell am I doing wrong?
1st you are lucky, because you replaced '\0' by '\n' and you had
hopefully another '\0' to stop it right after.
now, on PC's, in Text mode (in which C++ streams are in by default),
10's (\n) are converted into 13/10's (\r\n) for portability. That's
because DOS's way of handling things is broken. Other operating
systems, like Unix (10), TRS-80 DiskBasic (13), TRS-80 OS/9 (13) are
sane. I think Macs are 13 too. I'm under the impression that most home
computers of the '80's used 13, not only the TRS-80.
matju
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)
|