clarificaiton with pointers

Joined
Jul 6, 2010
Messages
6
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top