Created
July 4, 2015 20:55
-
-
Save cj3kim/a991074d1261ec190ede to your computer and use it in GitHub Desktop.
Suffix Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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