#include<stdio.h>
void count(char* string[])
{
int i,j,letter,number;
for(i=0;i<j;i++)
if(*string[i]=letter)
number++;
}
int main ()
{
int i,j,letter,number;
char string[]={"hello world"};
j=10;
letter='l';
count(char& string[i]);
printf("%c出现了%d次\n",letter,number);
return 0;
}
#include<stdio.h>
int counts(char* string,int j,char letter)
{
int number = 0;
for(int i=0;i<j;i++)
{
if(string[i] == letter)
number++;
}
return number;
}
int main ()
{
int j = 0;
int number = 0;
char letter;
char string[]={"hello world"};
j=10;
letter='l';
number = counts(string, j,letter);
printf("%c出现了%d次\n",letter,number);
return 0;
}
应该改为 string[]
第29行错了
char没定义