How to print "\n" or "\t"

This is a discussion on How to print "\n" or "\t" within the C Programming forums, part of the General Programming Boards category; Hi I have an multiline edit control, that the user can type anything. Mi problem es I need to save ...

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308

    How to print "\n" or "\t"

    Hi

    I have an multiline edit control, that the user can type anything.

    Mi problem es I need to save that text in a single line:
    Code:
    "Hello
    World"
    To be:
    Code:
    "Hello\nWorld"
    Any ideas about how to parse the text in C?
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,646
    Every time there is an instance of a '\n' character in the string replace it with the pair of characters '\\' (two backslashes needed in C code to get one backslash in output) and 'n'. Similar technique for '\t'.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 06:07 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 01:13 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 09:13 PM
  5. Replies: 1
    Last Post: 07-31-2002, 12:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21