Thread: #define

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    62

    #define

    Hi,

    I want to define something and I need direction on it.

    I want to define a comma (,) and the tab escape ('\t'), so I can use them later. Would it be:
    Code:
    #define TAB \t
    #define COMMA ,
    probably not, but I can't find it anywhere how to do it.

    thanks

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Try it. It should be OK depending on your context of how you use them. If you want to do something like this:

    Code:
    char tab = TAB;
    Then you need to do this:

    Code:
    #define TAB '\t'
    If you want the tab as a string then:

    Code:
    #define TAB "\t"
    Or leave off all quotes and use them in the code but that could get confusing... For example, originally, to assign the tab to a char, you'd have to do this:

    Code:
    #define TAB \t
    
    ...
    
    char c = 'TAB';  /* This just looks wrong. */

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    62
    Thank you

    Code:
    #define TAB '\t'
    worked fine!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer within a Struct
    By Bladactania in forum C Programming
    Replies: 11
    Last Post: 04-03-2009, 10:20 PM
  2. Why?!?
    By p3rry in forum C Programming
    Replies: 3
    Last Post: 01-08-2009, 12:52 PM
  3. size of an integer pointer
    By onebrother in forum C Programming
    Replies: 5
    Last Post: 07-09-2008, 11:49 AM
  4. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 09:22 AM
  5. float toolbar!
    By c-- in forum Windows Programming
    Replies: 5
    Last Post: 02-04-2003, 09:44 AM