printf removes \

This is a discussion on printf removes \ within the C++ Programming forums, part of the General Programming Boards category; Hey, i am trying to make a concole program, and i wish to have a sort of title: PHP Code: ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    England, Norwich
    Posts
    38

    Question printf removes \

    Hey, i am trying to make a concole program, and i wish to have a sort of title:
    PHP Code:
    #####################################
    #   _____       _             _____ #
    #  / ____|     | |           / ____|#
    # | |          | |          | |     #
    # | |          | |          | |     #
    # | |____   _  | |____   _  | |____ #
    #  \_____| (_) |______| (_)  \_____|#
    #                                   #
    #  Command       Line         Chat  #
    #                                   #
    # By Michael Knights                #
    ##################################### 
    i tryed using printf() to do this like so:
    PHP Code:
      printf("\t\t\t ##########################\n"); 
      
    printf("\t\t\t #   _____        _                     _____     #\n"); 
      
    printf("\t\t\t #  / ____|       | |                   / ____|    #\n"); 
      
    printf("\t\t\t # | |                | |                  | |             #\n"); 
      
    printf("\t\t\t # | |                | |                  | |             #\n"); 
      
    printf("\t\t\t # | |____    _  | |____      _  | |____     #\n"); 
      
    printf("\t\t\t #  \_____| (_) |______| (_)  \_____|   #\n"); 
      
    printf("\t\t\t #                                                          #\n"); 
      
    printf("\t\t\t #  Command       Line         Chat          #\n"); 
      
    printf("\t\t\t #                                                          #\n"); 
      
    printf("\t\t\t # By Michael Knights                            #\n"); 
      
    printf("\t\t\t #########################\n"); 
    my problem is that printf uses back slashes as indenifers for thing like tab and newline so all the \ in the asii art get removed when the program complies.

    i was wondering if any of you smart people knew of another way to print the chartors to the screen with out lossing the \'s

    Thanks.

  2. #2
    tao
    tao is offline
    Registered User
    Join Date
    Jun 2006
    Posts
    26
    Double up each "\" (i.e. "\\"). "\" is an escape character, so to escape itself (to ouput itself) you have to use two.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    England, Norwich
    Posts
    38
    Thanks Man works Perfect now!

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Code:
    printf("\t\t\t #  \_____| (_) |______| (_)  \_____|   #\n");
    If you have compiler warnings on you should get a warning to the effect that \_ isn't a valid escape sequence.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IF CONDITION plese help
    By birumut in forum C Programming
    Replies: 12
    Last Post: 03-06-2009, 08:48 PM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 08:38 AM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM
  4. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 08:23 AM
  5. Drawing tables in C
    By stanoman in forum C Programming
    Replies: 5
    Last Post: 10-09-2003, 10:14 AM

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