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


Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given


answer for tcs is working question

C Program for DIVISER   void main() {           int result,number,min;           clrscr();           printf("ENTER THE NUMBER=");           flushall();

How to Create A Data File? A data file should be created before it can be processed. A stream-oriented data file is able to be created in two ways. One is to create the file st

Define Functions with arguments and no return values The calling function will read a data from the terminal and pass it on to called as function and this will work good as the

The goto statement This statement can be used to branch to another statement of the program. This is rarely used as it violates the principle of structured programming. Though

when you allocate memory with new[], you ought to free the memory via delete[]. While you allocate memory along 'new', then use 'delete' with no the brackets. You employ new[] to a