I needed to test something and programmed this little bit of code(shown below). I can't understand why the first print works and the second doesn't. The output of this program is just
this prints
but it should be
this prints this doesn't print i: 1
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(char *str) {
char *z[1];
strcpy(*z, "z");
int a;
a = strcmp(str, *z);
return a;
}
int main() {
int i;
char *name[1];
printf("this prints\n");
strcpy(*name, "y");
i = cmp(*name);
printf("this doesn't print i:%d", i);
return 0;
}