473,385 Members | 2,013 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,385 software developers and data experts.

Macro in main function

hi
if some one know the asnswer of this question then send me
thnaks
macros in which swap two number without using 3rd variable and then call
Macro in main function
Jun 5 '07 #1
14 1752
DeMan
1,806 1GB
Hi HIRA HAMEED,
Welcome to thescripts. I'm sure you will find a wealth of information available here. At this stage, I am not sure how best to classify your question, so I will pass it to the "Miscellaneous Question" forum. The experts there may have a better idea of what direction to point you in.

In future, you can access a whole host of forums by selecting from theoptions on the blue bar near the top of the screen.

I hope the experts can help you out!
Jun 5 '07 #2
pbmods
5,821 Expert 4TB
Are you looking for a C/C++ macro? Or is this a macro for an application such as MS Word?
Jun 5 '07 #3
Motoma
3,237 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. a = a + b;
  2. b = a - b;
  3. a = a - b;
  4.  
Jun 5 '07 #4
pbmods
5,821 Expert 4TB
Check out the XOR Swap Trick.
Jun 6 '07 #5
Motoma
3,237 Expert 2GB
Check out the XOR Swap Trick.
You are right, the XOR is much better suited as it will never cause an overflow:
Expand|Select|Wrap|Line Numbers
  1. a = a ^ b
  2. b = a ^ b
  3. a = a ^ b
  4.  
Jun 6 '07 #6
Savage
1,764 Expert 1GB
You are right, the XOR is much better suited as it will never cause an overflow:
Expand|Select|Wrap|Line Numbers
  1. a = a ^ b
  2. b = a ^ b
  3. a = a ^ b
  4.  
This will also not cause a overflow.See this thread

Savage
Jun 7 '07 #7
Motoma
3,237 Expert 2GB
This will also not cause a overflow.See this thread

Savage
Well, it does overflow, but in C and C++ that overflow does not matter. However, in other languages you may have an exception thrown causing your program to end prematurely. With an XOR this will not happen.
Jun 7 '07 #8
Savage
1,764 Expert 1GB
Well, it does overflow, but in C and C++ that overflow does not matter. However, in other languages you may have an exception thrown causing your program to end prematurely. With an XOR this will not happen.
Well,this is a C/C++ forum after all..

:P

Savage
Jun 7 '07 #9
Motoma
3,237 Expert 2GB
Well,this is a C/C++ forum after all..

:P

Savage
Check again baby, we're in the Miscellaneous forum.
Jun 7 '07 #10
Savage
1,764 Expert 1GB
Check again baby, we're in the Miscellaneous forum.
Duh!

Why did I thought this is C/C++ forum?

LOL
Jun 7 '07 #11
Motoma
3,237 Expert 2GB
Duh!

Why did I thought this is C/C++ forum?

LOL
Like I have previously stated: you're crazy!
Jun 7 '07 #12
pbmods
5,821 Expert 4TB
Why did I thought this is C/C++ forum?
Because we still don't know what language the original poster is using (hint, hint, HIRA HAMEED...).
Jun 7 '07 #13
Savage
1,764 Expert 1GB
Because we still don't know what language the original poster is using (hint, hint, HIRA HAMEED...).
Aha,he posted this in C/C++ forum,now I remember.

Savage
Jun 7 '07 #14
Motoma
3,237 Expert 2GB
Aha,he posted this in C/C++ forum,now I remember.

Savage
You sure do have all the answers, don't you Savage?
Jun 7 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Shi Jin | last post by:
Hi there, While I was trying to disassemble a simple C program for my OS course, I found that the call to function longjmp is actually called to siglongjmp under linux. And similarly, under...
8
by: lasek | last post by:
Hi...in some posts i've read...something about using macro rather then function...but difference ??. Best regards....
8
by: baumann | last post by:
hi all, i defined a macro like the below #define initSock() \ do{\ WSADATA ws_data;\ WSAStartup(0x0202,&ws_data);\ }while(0)
44
by: Simon Morgan | last post by:
Hi, Can somebody please help me grok the offsetof() macro? I've found an explanation on http://www.embedded.com/shared/printableArticle.jhtml?articleID=18312031 but I'm afraid it still...
19
by: Mockey Chen | last post by:
I using #define as following: #include <stdio.h> #define LOG_PREFIX "Current function: <" __FUNCTION__ ">: " int main() { printf(LOG_PREFIX "some thing.\n"); return 0; }
34
by: Umesh | last post by:
how to convert a program to a function/macro and put it in a header file? is there any shortcut method for this? thanks.
6
by: jason | last post by:
Hi, I learned my lesson about passing pointers, but now I have a question about macros. Why does the function work and the MACRO which is doing the same thing on the surface, does not work in...
5
by: Peng Yu | last post by:
Hi, It is benifitical to use macro in certain cases. http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/index.html However, I found that it is not easy to debug a macro. For example,...
16
by: mdh | last post by:
I have asked a few questions about Macros...and think what I have been missing ...and which all who have replied clearly understand...is that this is a Pre-processor action. Hopefully the above is...
36
by: sh.vipin | last post by:
how to make large macro paste the code as it is Problem Explanation '-- For example in the program below /* a.c - starts here */ #define DECL_VARS() \ unsigned int a0;\ unsigned int a1;\...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.