C语言,用结构体把每个单词的第一的字母改成小写
答案:2 悬赏:50 手机版
解决时间 2021-02-05 21:05
- 提问者网友:且恨且铭记
- 2021-02-05 05:46
3)功能:输入一行英文文本,将每一个单词的第一个字母变成小写。
下面是我改完之后的程序,但是总是报错,求大神帮忙呀!!!
#include
#include
#include
char fun(char *p)
{
int k=0;
do while(*p!='\0')
{
if(k==0&&*p!=' ')
{
*p=tolower(*p);
k=1;
}
else if(*p!=' ')
k=1;
else
k=0;
p++;
}
}
main()
{
char str[81];
printf("please input a English text line:");
gets(str);
printf("The original text line is :");
puts(str);
fun(str);
printf("The new text line is :");
puts(str);
}
报错的是
: error C2059: syntax error : '}'
: warning C4508: 'main' : function should return a value; 'void' return type assumed
最佳答案
- 五星知识达人网友:污到你湿
- 2021-02-05 06:20
#include
#include
#include
char fun(char *p)
{
int k=0;
do //do while的格式错了
{
if(k==0&&*p!=' ')
{
*p=tolower(*p);
k=1;
}
else if(*p!=' ')
k=1;
else
k=0;
p++;
}while(*p!='\0');
return *p; //你的没有返回值
}
void main() //加个void表示没有返回值
{
char str[81];
printf("please input a English text line:");
gets(str);
printf("The original text line is :");
puts(str);
fun(str);
printf("The new text line is :");
puts(str);
}
全部回答
- 1楼网友:拾荒鲤
- 2021-02-05 07:10
#include
#include
#include
void fun(char *p)//void
{
int k=0;
while(*p!='\0')//do
{
if(k==0&&*p
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯