Printing \n?

This is a discussion on Printing \n? within the C Programming forums, part of the General Programming Boards category; How do I effectively add a "\n" to a string without the compiler interpreting it as a new line? For ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    12

    Printing \n?

    How do I effectively add a "\n" to a string without the compiler interpreting it as a new line? For example, if I want to print out the following line:
    Code:
    blahblah\nblahblah
    rather than
    Code:
    blahblah
    blahblah
    Last edited by killiansman; 09-15-2008 at 11:13 AM.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    "\\n"
    btw, code tags close with a / not a \

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If you want to actually print a \, you use \\ to tell the compiler to make one \ character.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  2. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 02:20 AM
  3. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 07:10 PM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 03:46 AM
  5. Printing using DrawText() or TextOut()
    By Eversman in forum Windows Programming
    Replies: 1
    Last Post: 05-24-2004, 12:12 PM

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