I have a double pointer, and I need to read words into it. Here's what I have so far:
Code:
while(fscanf(keywordFile,"%s",keyinputter)==1){
keys_cnt++;
}
keywords = (char**)calloc(keys_cnt,sizeof(char));
rewind(input);
int y=0;
while(fscanf(keywordFile,"%s",keyinputter)==1){
keywords[y] = strdup(keyinputter);
y++;
}
printf("%s\n",keywords[0]);
keyinputter is an array of size 30. The first while loop finds the number of words in a file so that I can calloc the correct amount of space for the double pointer, keywords. The second while loop is supposed to read the words into the double pointer, but when I run a print statement to print the string at keywords[0], it only prints null and not the word. Am I assigning the strings to the double pointer in the wrong way?