#include <stdio.h> # define MAXARRAYSIZE 5 main() { int intarray[MAXARRAYSIZE]; int *iap; /* a pointer to an int */ int k; /* loop induction variable */ /* one implementation */ iap = intarray; for ( k = 0; k < MAXARRAYSIZE; k++) { *iap = k + 1; iap++; } iap = intarray; for ( k = 0; k < MAXARRAYSIZE; k++) { printf("%d\n", *iap); iap++; } /* another implementation */ for ( k = 0; k < MAXARRAYSIZE; k++) { intarray[k] = k + 1; } for ( k = 0; k < MAXARRAYSIZE; k++) { printf("%d\n", intarray[k]); } }
The blog provides study material for Computer Science(CS) aspirants. Mostly says "material nahi milta, padhun kahan se.", I think If you can not find content on the Internet, then you are not a CS student. Dedicated to (Prof. Rakesh Kumar, DCSA, K.U.Kurukshetra, HARYANA, INDIA)- "Ek teacher ka bahut jyada padhna, bahut jyada jaroori hota hai."
Sunday, 13 October 2013
use of array versus pointer references
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment