Thread: Print new line using 10 in decimal

  1. #1
    Registered User FernandoBasso's Avatar
    Join Date
    Oct 2011
    Location
    Brazil
    Posts
    45

    Print new line using 10 in decimal

    How would I print a new line using the decimal 10?

    I have tried:

    Code:
    printf("Hello \10 world.\10");
    But it doesn't print a new line. However, if I use octal:

    Code:
    printf("Hello \12 world.\12");
    Then it does work.

    In hexadecimal, I would use \xA, and that makes it easy to see the difference. But, for example, 10 in decimal is said to be New Line. However, 10 in otcal is Backspace. How do I write the code so that C is able to diferentiate 10 decimal from 10 octal?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    C syntax - Wikipedia, the free encyclopedia
    You're stuck with hex or octal constants.

    You could do
    printf("Hello world%c", 10 );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User FernandoBasso's Avatar
    Join Date
    Oct 2011
    Location
    Brazil
    Posts
    45
    Quote Originally Posted by Salem View Post
    C syntax - Wikipedia, the free encyclopedia
    You're stuck with hex or octal constants.

    You could do
    printf("Hello world%c", 10 );
    Reading. Thanks. (SOLVED)
    Last edited by FernandoBasso; 12-30-2011 at 06:05 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to open files and print line by line in shell
    By omega666 in forum Linux Programming
    Replies: 4
    Last Post: 04-15-2011, 04:54 PM
  2. Replies: 6
    Last Post: 01-24-2011, 03:01 PM
  3. Print to hyperterminal in Hexa (Or Decimal)
    By pedropbr in forum C Programming
    Replies: 2
    Last Post: 11-03-2010, 10:03 PM
  4. Unable to print decimal part of the value. Can someone help?
    By matthayzon89 in forum C Programming
    Replies: 2
    Last Post: 09-18-2010, 10:55 PM
  5. %g doesn't print as many decimal places as %f
    By octoc in forum C Programming
    Replies: 1
    Last Post: 03-31-2008, 12:16 PM