プログラムでは、入力からスキャンする必要があります
scanf("%s",currWord);
定義されていない数の行に含まれる、定義されていない数の単語。
単語を文字列の 2 次元配列に入れたい。弦の長さは固定です[MAX_WORD_LEN+1]
私の考えは:
int row=10 //10 lines for starting
int col=5 //5 words in each line for starting
int i;
typedef char word[MAX_WORD_LEN+1]; //new type of 11char lenght string
word** matrix; //2 dimensional array (pointers) with no memory
matrix = malloc(row*sizeof(word*)); //allocate row number of word* (word pointer) size
for(i=0;i<row;i++)
{
matrix[i] = malloc(col*sizeof(word)); //allocate col number of words to each row
}
だから、それが正しいかどうかはわかりません。
いくつかの助けとヒントをいただければ幸いです..
編集:
入力から単語を受け取るとき、必要に応じてメモリ (行数と各行の単語数) を増やす必要があります。どうすればよいですか? (再割り当て?)
次のことを行う必要があります。