473,809 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

diff between #define & const

hello ,
what's the basic difference between #define & const.
plz reply.
thanks in advence.
Nov 13 '05 #1
2 3998
ROSY <de************ **@rediffmail.c om> scribbled the following:
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 (pa*****@cc.hel sinki.fi) ---------------------------\
| 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
Nov 13 '05 #2
"ROSY" <de************ **@rediffmail.c om> wrote in message
news:73******** *************** ***@posting.goo gle.com...
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
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2548
by: bo | last post by:
And why and where one should use one vs. the other? Verbally, it seems like semantics to me--but obviously there is some actual difference that makes references different and or preferable over pointers in some cases... TIA
16
2490
by: Steven T. Hatton | last post by:
In the following code, the only way I can figure out to pass an array of const is by setting the template argument to const in the instanciation expression. It would be (or seem to me) better if I could set that qualifier in the function call. Can that be done? #include <iostream> using std::ostream; using std::cout;
1
2945
by: Santa | last post by:
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static', also at what conditions it can be used?. Thanks.
71
4367
by: ROSY | last post by:
1. How would you use the functions memcpy(), memset(), memmove()?
4
4958
by: Andreas Kasparek | last post by:
Hola! I'm preparing my master thesis about a XML Merge Tool implementation and was wondering if there is any open standard for XML diff regarding topics like: - is a diff result computed on the ordered or unordered xml node tree of the compared documents? - what identifiers/criteria should be used by default to match elements of the same type in different documents? - should a diff tool consider move operations or only insert/delete
6
2607
by: AMP | last post by:
I have all these #define commands in a c++ file I am converting to C#. They usually have a value assigned to them: #define BSL_TXBLK 0x12 What is the c# equivalent for this. (It wont accept these,I dont think) "Cannot define/undefine preproccessor symbols after first token in file" Thanks,
4
1751
by: adnan.yalin | last post by:
Could you suggest solutions to a problem currently I have? Problem: Let's say I have many different commands and I call a different function for each (void handle_command_1(*data), void handle_command_2(*data), etc.) through my DispatchCommand(*data) function. For example, only implementing two of those functions is enough for an executable, but for another executable other functions are necessary. There can be many executables like...
5
3236
by: MoslyChang | last post by:
Hi, All When I look at effective c++,item2 and item3. I have some basic questions , Does anyone be familar with this topic? it suggests const is perfer to #define, then I think how to replace #define with const. example: 2 header file StringGrid1.h StringGrid2.h
23
3925
by: anon.asdf | last post by:
Hello! In the following code-snippet, is it possible to initialize each element of arr, with STRUCT_INIT? struct mystruct { int a; char b; };
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.