Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   clarificaiton with pointers (http://www.velocityreviews.com/forums/t868329-clarificaiton-with-pointers.html)

satya123 02-15-2012 02:56 AM

clarificaiton with pointers
 
Hi all,

I was wondering whether the following code is proper i want to modify the values of a and b

#include <stdio.h>

void modify(int &, int &);

int main(int argc, char *argv[])
{
int a=12;
int b=13;

modify(&a, &b);
}

void modify(int &p, int &q)
{
int *f1, *f2;
f1=p;
f2=q;
*f1 = 21;
*f2 = 31;
printf("%d%d",*f1,*f2);
}

Is it possible to pass the address parameters like the one i have shown? i know it is mistake and we need to give pointers to actually make it work? but why the above code does not work?

thanks in advance,

regards,
satya


All times are GMT. The time now is 04:55 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.