Example of pointers, C/C++ Programming

#include "stdafx.h"

#include iostream

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

            int NumbHold[5];

            int * ptrNumb;

            ptrNumb= NumbHold; 

            *ptrNumb= 10;

            ptrNumb++; 

            *ptrNumb= 20;

            ptrNumb= &NumbHold[2]; 

            *ptrNumb= 30;

            ptrNumb= NumbHold + 3; 

            *ptrNumb= 40;

            ptrNumb= NumbHold; 

            *(ptrNumb+4) = 50;

            for (int n=0; n<5; n++)

                        cout << NumbHold[n] << ", ";

            cout << endl;

            return 0;

}

Output:

10, 20, 30, 40, 50, 
Posted Date: 4/1/2013 3:24:55 AM | Location : United States







Related Discussions:- Example of pointers, Assignment Help, Ask Question on Example of pointers, Get Answer, Expert's Help, Example of pointers Discussions

Write discussion on Example of pointers
Your posts are moderated
Related Questions

Define Register Storage Class - computer programming? The Storage class register notify the compiler that the associated variables must be stored in high-speed memory register.

In this sub-task will you implement three functions for the final three function prototypes that will do exactly the same as the three functions that you have just written. This ti

The default Constructor and Destructor If you fail to write a constructor and destructor function,  the compiler automatically supplies them for you. These functions have publi

Virtual Functions The keyword virtual was previously used to resolve ambiguity for a class derived from two classes, both having a common ancestor. These classes are known as v

Question : (a) One of the most common sorting techniques we have in programming is the ‘Bubble Sort'. This technique will be used to sort an array of elements in ascending or

write c++ program to decode the given code. in mobile keypad the integers from 1 to 9 will display the characters from a to z and 0 will assign a space

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial gues

Pointers to Objects Passing and returning of objects is, though, not very efficient since it includes passing and returning a copy of the data members. This problem can be elim