Skip to content

Instantly share code, notes, and snippets.

@ovidiucs
Created September 23, 2012 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovidiucs/3772984 to your computer and use it in GitHub Desktop.
Save ovidiucs/3772984 to your computer and use it in GitHub Desktop.
Pointer Offset and Subscript Operator Syntax
#include<stdio.h>
#include<strings.h>
int main(void)
{
/* Looping Variables */
int i = 0, j = 0;
int num_states = 4;
char *states[]= {"California","Oregon","Washington","Texas"};
for(i = 0; i < 4; i++)
{
for ( j = 0; j < strlen(states[i]); j++)
{
/*printf("\t%c \t %p \n",states[i][j],&states[i][j]);*/
printf("\t%c\n",*(*states + j) );
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment