-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
chaka wrote:
On 24 Jan 2005 10:28:06 -0800, "bacadman" <ba******@gmail.com> wrote:
I have a variable that seems to be placing a newline when outputting to
a file. How can I test to see if this is the case.
if(line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
Which is a good way to kill off the trailing newline in a string.
But, the OP didn't make it clear that this is what is happening. It could be
that the newline is a single character (as in printf("%c",'\n'); ), or even
imbedded at some point inside a string (as in printf("%s","abc\n123"); ).
Neither of these cases are addressed by your (good) code fragment.
- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFB9VcyagVFX4UWr64RAg/qAKDwWTBYHWYam+/EVFHRH4E7mTB3BACgyPoC
NZMIpob3XRWgMM1Rgl15kTw=
=iICq
-----END PGP SIGNATURE-----