ですので、私は完全な答えを探していません。私はちょうどこれから始めるべきか分からない。私は名前の完全なポインタ配列を宣言しているコードを持っています。目的は、名前を検索し、使用されている各文字を数えるためのコードを書くことです。ポインタ配列を使用した文字数の検索は、
/*
* Search through each character in s,
* which is array containing n strings,
* and update the global count array
* with the correct character counts.
* Note: check the examples to see
* if the counts should be case
* sensitive or case insensitive.
*/
void letterCount(char * s[], int n){
//Implement this function
int c = 0,x; // This is what I've done and I
char p = 'a', j = 'z'; // don't know where im messing up.
while (s[c] != '\0') { // I know I can't compare pointer
if (s[c] >= p && s[c] <= j){ // and integer.
x = *s[c] - 'a';
count[x]++;
}
c++;
}
}
/*
* Initialize each value in the global
* count array to zero.
*/
void initializeCount(){
//Implement this function
int i;
for (i = 0; i < 26; i++){ // Also not sure if this is correct.
count[i] = 0;
}
}
出力では、count[26]
という配列に文字を使用する必要があります。 お願いします。
文字列は1文字以上の文字列です。長さは '\ 0'の最後の文字で示されます。そのため、少なくとも1つ( '\ 0'ターミネータのみがある場合)です。 (私にとって、あなたはこれを理解しているようです)あなたが考慮しなかったもの: 's'は文字列ではなく**文字列の配列**です。したがって、i = 0 ... 'n' - 1で' s [i] 'を反復する外側ループが存在しなければなりません。それぞれの' s [i] 'にコードを適用しなければなりません(char * "最初に説明したような文字列を指しています) – Scheff
_「どこがうんざりしているのかわかりません」_問題の内容を指定するのを気にしなかったからです。エラーはありますか?それともうまくいくのですか? –