clarificaiton with pointers

Discussion in 'C Programming' started by satya123, Feb 15, 2012.

  1. satya123

    satya123

    Joined:
    Jul 6, 2010
    Messages:
    6
    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
     
    satya123, Feb 15, 2012
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil
    Replies:
    1
    Views:
    649
    llewelly
    Sep 16, 2003
  2. muser
    Replies:
    3
    Views:
    765
    Ron Natalie
    Sep 18, 2003
  3. A
    Replies:
    3
    Views:
    459
    Alan Kelon
    Oct 29, 2003
  4. Xamalek
    Replies:
    7
    Views:
    690
  5. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    680
Loading...

Share This Page