Thread: pointers.......

  1. #1
    Registered User
    Join Date
    Oct 2002


    i just learned them ( somewhat) and i am very confused about the return value i recieve....

    this is what i made, if anyone could explain why its NOT giving me 10 , i would greatly appreciate it.

    #include <iostream>

    using std::cout;
    using std::cin;
    using std::endl;

    void fn( int );

    int main ()


    cout<<" The value of intvar is:"<<fn<<endl;

    return 0;


    void fn( int intvar)

    int intVar;

    int *pintVar;

    pintVar = & intVar;

    *pintVar = 10;


    it prints out 00401221


  2. #2
    Registered User jawwadalam's Avatar
    Join Date
    May 2002
    It prints this because fn is a name of function... so the cout statement displays the addresss of the function fn()...
    Well you can get your required result.. of changing a variable's value.. in another.. function...... check this code.. this can be used for the purpose...
    #include <iostream.h>
    #include <conio.h>
    void fn( int &);
    using std::cout;
    using std::cin;
    using std::endl;
    int main ()
      int intvar;
      cout<<" The value of intvar is:"<<intvar<<endl;
      return 0;
     void fn( int &pintVar)
      pintVar = 10;
    One day you will ask what more important to you..
    I will say my life..
    and You will leave me with even knowing
    You are my Life (L)

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Or you can make cout << fn(blabla)
    and return a value in fn, so it can be displayed, the prototype will be:
    int fn(blabla);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM