I keep getting a segmentation fault when I try to copy "init" into my string array, and I can't figure out why. If I comment out the strcpy()
line, I don't get a segmentation fault and init
prints fine.
FILE *fp = fopen(argv[1],"r");
char *init = readToken(fp);
printf("%s",init);
char **words = malloc(sizeof(char*) * 2);
strcat(*words,init);
PS: readToken
is an fscanf
.