Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
@atul...mistakenly i have put w at place of t in my last post...i wana say On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote: Just replace your macro with its definition and you will understand. its not doing swapping of pointers...plz explain @dCode i expanded..but

Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
if you think the your expanded version is incorrect.You are wrong , because int * will hold pointer but you are not allocating address of x ..instead you are allocating x value as an address of x to *t.This wont work. so to make it work you need to save the address of x and y in temp pointers i.e

Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
I have taken form book...i am writing exact code #includestdio.h #define swap(a,b,c) c t;t=a,a=b,b=t; int main() { float a,x; a=20.0; x=30.0; float *p,*q; p=a,q=x; swap(p,q,float*); printf(%f %f,a,x); getchar(); } o/p=20.000 30.000 why not swapped??? On Mon, Oct 29, 2012 at 11:01 PM, atul

Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
well they should not , if you see it closely pointer p and q contain contain address of a and x. and swap() macro will swap value these pointers are holding i.e adress of a and xbut will it reflect address of a and x ???...NO so if you print the address p and q ...before and after the

Re: [algogeeks] C Function Pointer(Typedef)

2012-10-29 Thread Shafi Ahmad
The purpose of typedef is to assign alternative names to existing type. In your case statement typedef int (*pFunc) (int); just assign a new name pFunc to pointer to function declaration int (*pFunc) (int);. This statement is not define any variable. Please see below working code. #include