Thread: Basic pointer syntax

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    3

    Basic pointer syntax

    Hello, I would just like someone to help clarify some basic pointer syntax, and hopefully this post may be of use to some others also.

    Code:
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int nNumberofArgs, char* pszArgs[])
    {
        int nVar = 37;
        int* pnVar = &nVar;
        
        // the adress of the pointer
        // (where the pointer exists in memory)
        cout << &pnVar << endl;
        
        // the value contained in
        // the variable pointed to (nVar)
        cout << *pnVar << endl;
        
        // the address of the where the variable (nVar)
        // exists in memory
        cout << pnVar << endl;
        
        
        
        
        system("PAUSE");
        return 0;
    }
    Any comments would be much appreciated! Thanks.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    The comments and code agree.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM

Tags for this Thread