2 Replies - 280 Views - Last Post: 09 September 2011 - 11:12 AM Rate Topic: -----

#1 chiakko7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 08-October 07


Posted 09 September 2011 - 10:50 AM

i am in a program in c class the teacher is use to teaching more advanced students an is going fast and taking short cuts with out explaining what the heck she was doing or how the heck she got there when we ask questions she goes off on tangents and never answers the questions to make maters worse neither she or her teaching assistants speak English as a first language and both have heavy accents and even there writen instructions are in broken english could some one explain #define

Is This A Good Question/Topic? 0
  • +

Replies To: #define

#2 jimblumberg  Icon User is offline

  • member icon

Reputation: 4565
  • View blog
  • Posts: 14,417
  • Joined: 25-December 09

Re: #define

Posted 09 September 2011 - 10:56 AM

How about this link: C #define or maybe Preprocessor directives

Was This Post Helpful? 0
  • +
  • -

#3 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 234
  • View blog
  • Posts: 723
  • Joined: 11-June 11

Re: #define

Posted 09 September 2011 - 11:12 AM

The #define preprocessor directive creates symbolic constants --- constants represented as symbols --- and macros --- operations defined as symbols. The #define preprocessor directive format is

#define identifier replacement-text

When the above line appears in a program, all subsequent occurrences of identifier in that program will be replaced by replacement-text before the program is compiled.
For example,

#define PI 3.14159

replaces all subsequent occurrences of the symbolic constant PI with the numberic constant 3.14159. Symbolic constants enable the programmer to create a name for a constant and use the name throughout the program.

This construction has long been popular in C. However, you can't specify the data type of the constant using #define, which can lead to program bugs; so even in C #define has been superseded by const used with normal variables.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1