Thread: #define question

  1. #1
    Unregistered
    Guest

    #define question

    the character 'N' has the value of 78
    so would i define it as:

    #define N '78'

    so i can use it in this example:
    if (arr[i][j] == N ) {
    statement;
    }

    thanks

  2. #2
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    no
    '78' is not a character
    if you want to declare a character with ascii value of 78
    just use 78
    eg.,
    char c=78;

  3. #3
    Unregistered
    Guest
    thanks alot.. this is the help i was looking for.. now my program working and is successfully on its way.. thanks

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    But since you can say

    if ( arr[i][j] == 'N' ) {

    You don't need to define anything, and you don't need to know the ascii value for N, and you don't even care if your character set isn't ascii.
    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.

  5. #5
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    You are right , I was wrong , ascii has nothing to do with it , I meant the numerical value of the character .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing syscalls from C
    By lilcoder in forum C Programming
    Replies: 17
    Last Post: 09-19-2007, 02:27 PM
  2. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  3. macro (#define) question
    By Darrok in forum C++ Programming
    Replies: 30
    Last Post: 12-20-2001, 05:01 PM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM