Skip to content

Instantly share code, notes, and snippets.

@cj3kim
Created July 4, 2015 20:55
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 cj3kim/a991074d1261ec190ede to your computer and use it in GitHub Desktop.
Save cj3kim/a991074d1261ec190ede to your computer and use it in GitHub Desktop.
Suffix Array
#include <stdio.h>
#define MAXN 6
int main() {
char c[MAXN] = {'h', 'e', 'l', 'l', 'o' };
/*phao: Declare `a` as an array of 6 elements of pointer to char.*/
char *a[MAXN];
for (int i = 0; i < MAXN; i++) {
a[i] = &c[i];
}
a[5] = 0;
printf("%s\n", a[0]);
printf("%s\n", a[1]);
printf("%s\n", c);
printf("\n");
printf("%c\n", a[0][3]);
printf("%c\n", c[0]);
printf("%c\n", c[1]);
//Why is each pointer treated like an array?
//char c, which I declared as a
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment