#include <iostream>
using namespace std;
int F(char s1[]);
int main()
{
char s1[100]="Hello Word";
F(s1);
cout<<"单词的个数:"<<F(s1)<<endl;
return 0;
}
int F(char *s1)
{
int i,j=1;
for(i=0;s1[i]!='\0';i++)
if(s1[i]==' ')
j++;
return j;
using namespace std;
int F(char s1[]);
int main()
{
char s1[100]="Hello Word";
F(s1);
cout<<"单词的个数:"<<F(s1)<<endl;
return 0;
}
int F(char *s1)
{
int i,j=1;
for(i=0;s1[i]!='\0';i++)
if(s1[i]==' ')
j++;
return j;
}
数组的初始化:char s1[100]="Hello Word"
函数的声明:int F(char s1[])或int F(*s1);
函数的调用:F(s1);与cout<<F(s1);
函数的定义:int F(char s1[])或int F(char *s1);
if(s1[i]!=' ')是单引号,而不是双引号