Thread: My textbook is trying to torture me

  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,815
    Seems more like self-flagellation and blaming the textbook, rather than torture by textbook, IMHO.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    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, 09: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, 02: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, 10:04 PM