Windows 98 C application - text boxes and "\n"

N

NJSG

I'm creating a Dialog-Based Win32 file backup utility
for use with other application.
The problem is that I want to get the following in a
textbox:
doc1.txt: copied without errors.
doc2.txt: not copied!
doc3.txt: copied without errors.
doc4.txt: copied without errors.
but it does not recognize "\n". I had this problem in
Visual BASIC ( ~~ two years ago), and I didn't found re-
solution to it. Now, the problem remains the same, but
over Pelles C and in other application.

I anybody knows how to resolve this problem over C,
please tell me.

I'm using:
- Windows 98;
- Pelles C (this application uses WinAPI);
- MS-DOS "command /c copy" to backup the files.

Note: It shows "\n" as an unrecognized character. (shows
a black square).

--
Nuno Silva (aka NJSG)

=== - ===
My english isn't very good, because it isn't my first language. If you
found any mistake (or have problems understanding the post), tell me.
=== - ===
I have a 33.3 kbps Internet Dial-Up Connection.
Please wait by my replies with patience.
 
M

Malcolm

NJSG said:
but it does not recognize "\n".
I anybody knows how to resolve this problem over C,
please tell me.

Note: It shows "\n" as an unrecognized character. (shows
a black square).
In C the sequence "\n" inserts the numerical value 13, which is ASCII for
newline (1).
However that is all that is special about this value - it happens to be used
for a newline marker. If you pass it to a function which treats 13 as
something else, for instance maybe a graphic or a foreign character, then
all your newlines will be replaced by that character.
This is what must have happened. The Windows functions you are calling
handle the ASCII alphanumerical characters as you want, but not the control
characters.
Probably what you need to do is strip the newlines out and represent them by
the way you lay out text manually. Instead of passing "O rose thou are
sick/nthe invisible worm" pass "O rose thou art sick", reposition the
cursor, and pass "the invisible worm".

Another possibility is that the Windows function is looking for the sequence
"/r/n".

(1) Pedant's point goes here.
 
J

Joe Wright

NJSG said:
I'm creating a Dialog-Based Win32 file backup utility
for use with other application.
The problem is that I want to get the following in a
textbox:
doc1.txt: copied without errors.
doc2.txt: not copied!
doc3.txt: copied without errors.
doc4.txt: copied without errors.
but it does not recognize "\n". I had this problem in
Visual BASIC ( ~~ two years ago), and I didn't found re-
solution to it. Now, the problem remains the same, but
over Pelles C and in other application.

I anybody knows how to resolve this problem over C,
please tell me.

I'm using:
- Windows 98;
- Pelles C (this application uses WinAPI);
- MS-DOS "command /c copy" to backup the files.

Note: It shows "\n" as an unrecognized character. (shows
a black square).

First, note that "\n" is a string literal in C. Surely you mean '\n'
which is the newline character. C uses the single newline as the
line terminator.

Micro$oft, for historical reasons, uses two characters to terminate
a line; a '\r' and a '\n' or CR and LF. To the extent that Pelles C
is creating the text files, opening them with "w" mode or "wt" mode
rather than "wb", might add the CR for you.
 
J

Joe Wright

Malcolm said:
In C the sequence "\n" inserts the numerical value 13, which is ASCII for
newline (1).
However that is all that is special about this value - it happens to be used
for a newline marker. If you pass it to a function which treats 13 as
something else, for instance maybe a graphic or a foreign character, then
all your newlines will be replaced by that character.
This is what must have happened. The Windows functions you are calling
handle the ASCII alphanumerical characters as you want, but not the control
characters.
Probably what you need to do is strip the newlines out and represent them by
the way you lay out text manually. Instead of passing "O rose thou are
sick/nthe invisible worm" pass "O rose thou art sick", reposition the
cursor, and pass "the invisible worm".

Another possibility is that the Windows function is looking for the sequence
"/r/n".

(1) Pedant's point goes here.

Pedant's point.
I think you will find that '\n' on ASCII systems translates to the
LF or linefeed character, 012, 0x0a or 10. The expression '\r' is
the CR or carriage return character, 015, 0x0d or 13.
 
M

Martin Ambuhl

Malcolm said:
In C the sequence "\n" inserts the numerical value 13,

No, in C the sequence "\n" produces an implementation-defined value or
values on the output stream, just as "a" or "1" does. Don't mislead the
poor sap.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top