473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

#defines

Hello,

int main(){
int i=2,j=3;

printf("%d %d",i,j);

#define i j
#define j i

printf("%d %d",i,j);

}

What is the ouput in both the cases

Could anyone explain which tokens are considered while preprocessing.

Is the succesive preprocessor token replaced

thaanx in advance

Rgds,
Naren.

Nov 13 '05 #1
2 2096
Naren wrote:
Hello,

int main(){
int i=2,j=3;

printf("%d %d",i,j);

#define i j
#define j i

printf("%d %d",i,j);

}

What is the ouput in both the cases


[modulo some whitespace]

int main()
{
int i = 2, j = 3;
printf("%d %d", i, j);
printf("%d %d", i, j);
}

--
Martin Ambuhl

Nov 13 '05 #2
"Naren" <na*************@in.bosch.com> writes:
#define i j
#define j i

Could anyone explain which tokens are considered while preprocessing.


The preprocessor won't expand a macro name from within its own
expansion. So i expands to j, which expands to i, which ends the
chain of expansions. Similarly for j.

[snippage]
--
"Some programming practices beg for errors;
this one is like calling an 800 number
and having errors delivered to your door."
--Steve McConnell
Nov 13 '05 #3

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

Similar topics

4
by: Mr.Tickle | last post by:
I have a .H file with tonnes of #define constants and I want to access that from C# but I dont want to rewrite the header file as a class. Is there a way after including that in MC++ to get...
4
by: Pelle Beckman | last post by:
Hi, I saw this code in an earlier post (not that there's anything wrong with it) #include <iostream> using std::cout; const int hour = 3600; const int min = 60;
2
by: Pelle Beckman | last post by:
Hi, This might be OT... Are there preprocessor defines in the C++ standard, such as __FILE__, __LINE__, __NAMESPACE__, __FUNCTION__, ec? If there is, were can I find a list? If there...
3
by: theotyflos | last post by:
Hi all, I have the following: /*--- SNIP ---*/ typedef struct Argument_s { char *address; int type;
7
by: John Dolinka | last post by:
I have a project of several files with #defines to setup a conditional compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the...
0
by: Ram Patel | last post by:
Hello, I have problem with Atlas XML script which defines behavior to tables for drag and drop like below: <script id="script1" type="text/xml-script"> <page > <components> <control...
6
by: Richard | last post by:
1. Are there any problems with having, for instance, POSIX's "open" function #defined more than once. In my case, these would be in different static libraries: #ifdef __cplusplus extern "C" {...
7
by: raghu | last post by:
Hello Everyone, I am using macro functions in my project the code is working correctly, But I have a doubt wheather the macro functions creates a context switching as in the case of normal...
2
by: =?Utf-8?B?VGhlQ3VyaW91c09uZQ==?= | last post by:
I have this situation where I need to access the #defines and typedefs defined in a C++ header file from a .NET Project (specifically C#). The C++ header file is from a medical device manufacturer...
14
by: Eliot | last post by:
I have a project which may be compiled with some #defines. Say:- #define firstdef #define seconddef If no defines are present or only one is present all is OK. I would like to add a self...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.