diff between #define & const

R

ROSY

hello ,
what's the basic difference between #define & const.
plz reply.
thanks in advence.
 
J

Joona I Palaste

ROSY said:
hello ,
what's the basic difference between #define & const.

#define is a preprocessor feature. It literally changes each occurence
of the macro with its expansion. The compiler will not even know of the
macro. It will only see the expansion. Const, on the other hand, is a
bona-fide storage class for real variables.

You know, ROSY, you seem to keep asking questions that typically arise
in the start of a beginning course of C. Don't you have a textbook you
could read or a professor you could talk to? If you keep this up, I'm
going to have to charge you.

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"No, Maggie, not Aztec, Olmec! Ol-mec!"
- Lisa Simpson
 
M

Mike Wahler

ROSY said:
hello ,
what's the basic difference between #define & const.

#define contains seven characters, the first of which
is a 'hash mark' or 'pound sign' depending upon the
local naming custom, the second of which is the lowercase
form of the fourth letter of the Roman alphabet, the
third of which is the lowercase form of the fifth letter
of the Roman alphabet, the fourth of which is the lowercase
form of the sixth letter of the Roman alphabet, the fifth
of which is the lowercase form of the ninth letter of the
Roman alphabet, the sixth of which is the lower case form
of the fourteenth letter of the Roman alphabet, and the
seventh of which is the lowercase form of the fifth letter
of the Roman alphabet.

const contains five characters, the first of which
is the lowercase form of the third letter of the Roman
alphabet, the second of which is the lowercase form of
the fifteenth letter of the Roman alphabet, the third
of which is the lowercase form of the fourteenth letter
of the Roman alphabet, the fourth of which is the lowercase
form of the nineteenth letter of the Roman alphabet, and
the fifth of which is the lowercase form of the twentieth
letter of the Roman alphabet.

IOW the basic difference is that they're spelled differently.

How long will you continue to post your homework questions
here instead of studying and learning the answers yourself?

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top