Mega Code Archive

 
Categories / C / Pointer
 

Using pointer arithmetic to access elements

#include <stdio.h> #define ISIZE 10 int main( ) {  char string10[ISIZE];  char *pc;  int icount;  pc=string10;  for(icount = 0; icount < ISIZE; icount++) {    *pc=getchar( );    pc++;  }  pc=string10 + (ISIZE - 1);  for(icount = 0; icount < ISIZE; icount++) {    putchar(*pc);    pc--;  } }