1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: What definition of #define cont 32767

  1. Feb 4, 2010 #1
    Hye.. i got this source code from internet.. i want to ask some quetion..

    here is the source code. but not a full code..

    include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>

    #define  cont 32767

    typedef struct dnode
            struct dnode *prev;
            int val;
            struct dnode *next;

    DNODE *rt;

    void insert()
        DNODE *temp,*temp1,*temp2;
        int i;
        printf("\nEnter the value of node:");


    what definition/meaning of "#define cont 32767" at line 5...can someone describe to me...thanks..
  2. jcsd
  3. Feb 4, 2010 #2


    User Avatar
    Science Advisor
    Homework Helper

    It means that "cont" is defined as a kind of alias for the number 32767. So if you would write

    int x = cont - 20;

    then x would be assigned the value 32767 - 20. Note that the replacement is done by the preprocessor, and is a literal replacement. So by the time your code reaches the compiler it is
    int x = 32767 - 20;

    In this case, I would recommend making it a proper integer, by using
    const int cont = 32767;

    Then, whenever you use "cont" in an expression, the compiler can apply type-checking which makes your code safer.
  4. Feb 4, 2010 #3
    In addition to CompuChip's response, the number may come from the range of integers in different situations. I can't confirm since the entire code is not pasted and I cannot see its use (Though as previously stated, with the define it is strictly a replacement), but if you are interested in further readings:

    http://home.att.net/~jackklein/c/inttypes.html [Broken]
    Last edited by a moderator: May 4, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook