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

Discussion in 'C Programming' started by NJSG, Jul 4, 2004.

  1. NJSG

    NJSG Guest

    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.
    NJSG, Jul 4, 2004
    #1
    1. Advertising

  2. NJSG

    Malcolm Guest

    "NJSG" <> wrote in message
    >
    > 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.
    Malcolm, Jul 4, 2004
    #2
    1. Advertising

  3. NJSG

    Joe Wright Guest

    NJSG wrote:
    > 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.

    --
    Joe Wright mailto:
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
    Joe Wright, Jul 4, 2004
    #3
  4. NJSG

    Jeff Guest

    "NJSG" <> wrote in message
    news:40e7e5ef$0$5847$...
    > I'm creating a Dialog-Based Win32 file backup utility
    > for use with other application.


    <snip>


    Win32 programming is off-topic.

    --
    Jeff
    comp.lang.c faq http://www.eskimo.com/~scs/C-faq/top.html
    Jeff, Jul 4, 2004
    #4
  5. NJSG

    Joe Wright Guest

    Malcolm wrote:
    > "NJSG" <> wrote in message
    >
    >>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.
    >
    >


    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.

    --
    Joe Wright mailto:
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
    Joe Wright, Jul 4, 2004
    #5
  6. NJSG

    Randy Howard Guest

    In article <40e7e5ef$0$5847$>, says...
    > I'm creating a Dialog-Based Win32 file backup utility
    > for use with other application.


    comp.os.ms-windows.programmer.win32
    Randy Howard, Jul 4, 2004
    #6
  7. Malcolm wrote:

    > "NJSG" <> wrote in message
    >
    >>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,


    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.
    Martin Ambuhl, Jul 4, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren D'Orlando
    Replies:
    1
    Views:
    718
    Steve C. Orr, MCSD
    Aug 19, 2003
  2. Jason

    password text boxes and viewstate

    Jason, Feb 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,186
    bruce barker
    Feb 13, 2004
  3. Julie

    Text boxes and read-only text

    Julie, May 12, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,062
    Julie
    May 12, 2004
  4. Neo
    Replies:
    0
    Views:
    330
  5. Stefan Mueller
    Replies:
    5
    Views:
    12,341
    jamesxa
    Jun 16, 2009
Loading...

Share This Page