c语言 这道题没人会么?

来源:百度知道 编辑:UC知道 时间:2024/09/21 16:48:35
输入一个英文句子(以句号结束),要求将句子中的单词分别打印出来。
我只作到这里 只能输出单个字符不能输出单词 谁会 帮助一下 谢谢
#include<stdio.h>
void main()
{
char c;
printf("输入一个句子:");
while(scanf("%c",&c),c!='.')
{

printf("%c\n",c);
}
}
据个例子吧
我手动输入:what are you doing
回车输出:what
are
you
doing
厉害的大哥们帮帮忙哦

用gets(a)
怎么把刚才的问题关闭了,我刚写好了- -!!!用C++的不知道可以不可以
#include <iostream>
using namespace std;

int main()
{
char a[100];
char *start,*end;
cout<<"输入你要输入的句子:";
gets(a);
start=end =a;
while(*end!='\0')
{
end++;
if(*end == ' ')
while(start<end)
{
cout<<*start;
start++;
}
if(start == end)
{
end++;
start =end;
cout<<endl;
}
}
if(*end=='\0')
while (start<end)
{
cout<<*start;
start++;
}
cout<<endl;
}

下面是C语言版本
#include <stdio.h>

int main()
{
char a[100];
char *start,*end;
printf("输入你要输入的句子:");
gets(a);
start=end =a;
while(*end!='\0')
{
end++;
if(*end == &#