clarificaiton with pointers

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

  1. satya123

    satya123

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

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:
    783
    llewelly
    Sep 16, 2003
  2. muser
    Replies:
    3
    Views:
    976
    Ron Natalie
    Sep 18, 2003
  3. A
    Replies:
    3
    Views:
    632
    Alan Kelon
    Oct 29, 2003
  4. Xamalek
    Replies:
    7
    Views:
    910
  5. Roger Leigh
    Replies:
    8
    Views:
    719
    Karl Heinz Buchegger
    Nov 17, 2003
  6. Richard Hayden
    Replies:
    1
    Views:
    845
    Rob Williscroft
    Nov 23, 2003
  7. Jonas Cord

    Pointers to pointers

    Jonas Cord, Apr 13, 2005, in forum: C++
    Replies:
    5
    Views:
    409
    Ioannis Vranos
    Apr 13, 2005
  8. cerr

    pointers, pointers, pointers...

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