Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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("%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
You can’t perform that action at this time.