各単語の単語と数を配列に格納しようとしていますstruct word
struct word{
char str[MAX_WORD_LENGTH];
int num;
}
inputFile = fopen("wordstat.txt", mode);
if(inputFile == NULL){
printf("Cannot open file\n");
return 1;
}
//scan through file to count number of possible words
while(fscanf(inputFile, "%s", scan)){
wordCount++;
}
rewind(inputFile);
struct word *words = malloc(wordCount * (sizeof *words));
文字列にアクセスしてメンバー変数 str に格納するにはどうすればよいですか? malloc を実行する前に初期化する必要がありますか?