こんにちは、構造体で strlen 関数を使用しようとしていますが、ひどく失敗しています。私のコードは次のとおりです。scanfの後、テーブルの最初の文字のみを取得し、最後の印刷でプログラムがクラッシュします。私が間違っている提案やアイデアはありますか? 主に、ユーザーはテーブルに英数字を入力し、strlen を使用して英数字の長さを抽出したいと考えています。
#include<stdio.h>
#include <string.h>
main(void)
{
int M,N;
struct word_pair /*structure */
{
char word[M]; // the alphanumeric
int lenght; //the lenght of alphanumeric
};
struct word_pair word_table[N]; // the table of alphanumeric and lenght
printf("Enter a frase:");
scanf("%c",&word_table[N].word[M]);
printf("\n Your frase is %c ",word_table[N].word[M]);
printf("\n %u ",(unsigned)strlen(word_table[N].word[M]));
}