Total members 11890 |It is currently Fri Apr 19, 2024 8:22 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Define integers arrays with pointers
cpp code
#include <stdio.h>

void main()
{
int Array[3];
Array[0] = 10;
Array[1] = 20;
Array[2] = 30;

int *pArray;
pArray = &Array[0];

printf("p The value pointed : %d\n", *pArray);
}


Another example:
cpp code
#include <stdio.h>

main()
{
int fred[] = { 10, 20, 30, 40, 50, 60, 70 };
int *joe = fred + 5;
int *alex = joe - 3;

fred[0] = 99;
joe[0] = 199;
alex[1] = 299;

int m;
for(m = 0; m < 7; m++) printf("%4d", m);
printf("\n");
for(m = 0; m < 7; m++) printf("%4d", fred[m]);
printf("\n");
}



Another example:
cpp code
#include <stdio.h>

void main()
{
int Array[3];
Array[0] = 10;
Array[1] = 20;
Array[2] = 30;

int *pArray;
pArray = &Array[0];

printf("p Value at this %d\n", *pArray);
pArray++;
printf("p Value at this%d\n", *pArray);
pArray++;
printf("p Value at this %d\n", *pArray);
}




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Arrays using Pointers
 Swap Using Pointers     -  
 Types of Pointers in C++     -  
 How to use pointers and what it means     -  
 Basic Pointers     -  
 pointers to derived types     -  
 Passing Pointers to function example     -  
 The using of pointers between two variables (Swaping)     -  
 References confuse me. How do they differ from pointers?     -  
 Defining arrays in ASP     -  
 Arrays in photoshop     -  



Topic Tags

C++ Arrays
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com