Like Tree1Likes
  • 1 Post By grumpy

My textbook is trying to torture me

This is a discussion on My textbook is trying to torture me within the C Programming forums, part of the General Programming Boards category; How do I print "\n" or "\t"? Apparently neither \n nor \n work....

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    99

    My textbook is trying to torture me

    How do I print "\n" or "\t"? Apparently neither \n nor \\n work.


  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    99
    ok, now \\n seems to be working. i swear it wasn't a second ago.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I'd say it's doing a pretty good job of it! <smile>

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,253
    Seems more like self-flagellation and blaming the textbook, rather than torture by textbook, IMHO.
    Matticus likes this.
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,057
    This seems to be more a question of notation. For example when you say to print "hello\nworld\n" what exactly do you mean? As programmers we agree on a convention that this means to print the the string "hello" on one line, then "world" on the next. This is the way the compiler interprets it. If you want to actually print the following

    "hello"\n"world"\n

    on a single line then the convention specifies you must type "\"hello\"\\n\"world\"\\n\n". Maybe its confusing at first but read it carefully left to right: Start-of-string, literal-", hello, literal-", literal-\, n, literal-", world, literal-", literal-\, n, newline, End-of-string.

    Text-Editors with syntax highlighting can help you to digest the notation a little easier without "self-flagellation"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Textbook for High School Students
    By mbeebe in forum General Discussions
    Replies: 14
    Last Post: 12-19-2009, 08:40 AM
  2. Awesome C++ College Textbook
    By HarleyJohn in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2009, 11:35 AM
  3. Poll - Terrorism & Torture
    By Kybo_Ren in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 12-04-2006, 01:08 PM
  4. Replies: 4
    Last Post: 04-23-2006, 02:03 PM
  5. Please suggest a good C++ textbook
    By puja399 in forum C++ Programming
    Replies: 7
    Last Post: 11-19-2005, 09:04 PM

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