What definition of #define cont 32767

  • Thread starter Thread starter woofr_87
  • Start date Start date
  • Tags Tags
    Definition
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
woofr_87
Messages
4
Reaction score
0
Hye.. i got this source code from internet.. i want to ask some quetion..

here is the source code. but not a full code..
PHP:
include <stdio.h>
#include <conio.h>
#include <stdlib.h>

#define  cont 32767

typedef struct dnode
	{
		struct dnode *prev;
		int val;
		struct dnode *next;
	}DNODE;

DNODE *rt;

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

	temp=(DNODE*)malloc(sizeof(DNODE));
	temp->val=i;
	if(rt==NULL)
what definition/meaning of "#define cont 32767" at line 5...can someone describe to me...thanks..
 
on Phys.org
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.
 
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://en.wikipedia.org/wiki/Integer_(computer_science)
http://home.att.net/~jackklein/c/inttypes.html
 
Last edited by a moderator: