次の点を考慮してください。
typedef struct wordType
{
char word;
uint count;
};
int main( void )
{
typedef struct wordType * WORD_RECORD;
WORD_RECORD arrayOfWords = malloc(10 * sizeof( WORD_RECORD) );
FILE * inputFile;
char temp[50];
uint index;
inputFile = fopen( "input.txt", "r");
while( fscanf( inputFile, "%s", temp) == 1 )
{
printf("%s\n", temp );
arrayOfWords[index].word = malloc( sizeof(char)*(strlen(temp) + 1 ));
strcpy( arrayOfWords[index].word, temp );
}
index++;
}
scanf を介して単語が取り込まれるたびに malloc しようとしています。しかし、なぜこれがうまくいかないのか分かりません。エラーが発生しています:
warning: assignment makes integer from pointer without a cast
warning: passing argument 1 of ‘strcpy’ makes pointer from integer without a cast