?
Du kannst Zeiger und beide Dimensionen übergeben:
void zaehle_buchst(char *text, int *zeichen, int d1, int d2) {
int i=0,j;
while( text[i] != '\0' )
{
for(j=0; j<d1; j++) {
if( text[i] == zeichen[j*d2] )
{
zeichen[j*d2+1]++;
}
}
i++;
}
}
int main()
{
const int ARR = 5;
char text[]="Hallo wie gehts euch";
int vokalcount[][2]={ {'a',0},{'e',0},{'i',0},{'o',0},{'u',0} };
zaehle_buchst(text,vokalcount,ARR,2);
...
}
Oder, was mir in diesem Falle besser gefallen würde
typedef struct
{
char c;
int i;
}CCount;
void zaehle_buchst(const char *text, CCount *cc, size_t laenge) {
int i=0,j;
while( text[i] != '\0' ) {
for(j=0; j<laenge; ++j) {
if( text[i] == cc[j].c ) {
++cc[j].i;
}
}
++i;
}
}
int main()
{
const int ARR = 5;
char text[]= "Hallo wie gehts euch";
CCount vokalcount[]={ {'a',0},{'e',0},{'i',0},{'o',0},{'u',0} };
zaehle_buchst(text, vokalcount, 5);
....
}
fflush(stdin) sollte vermieden werden, schau mal in die FAQ.