Has anyone ever encountered this before in C:
When I run the above code, a blank line is printed! Is something wrong?
EDIT: I probably shouldn't be blaming this on the compiler (Apple's gcc). It's probably just my poor coding skills. Still, what is happening?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
char **strings;
int i;
strings = (char **) malloc(65);
strings[0] = (char *) malloc(strlen("string") + 1);
strcpy(strings[0], "string");
for (i = 1; i < 65; i++)
strings[i] = NULL;
printf("%s\n", strings[0]);
free(strings[0]);
free(strings);
return 0;
}
When I run the above code, a blank line is printed! Is something wrong?
EDIT: I probably shouldn't be blaming this on the compiler (Apple's gcc). It's probably just my poor coding skills. Still, what is happening?