题目内容
给定程序MODI1.C中函数fun()的功能是:将p所指字符串中每个单词的最后一个字母改成大写(这里的“单词”是指由空格隔开的字符串)。 例如,若输入”I am a student to take the examination.”,则应输出”I aM A studenT tO takE thE examination.”。 请修改程序中的错误之处,使它能得出正确的结果。 注意:不要改动main()函数,不得删行,也不得更改程序的结构。 #include<ctype.h> #include<stdio.h> #include<string.h> void fun(char *p) int k=0; for(; *p;p++) if(k) /**********found**********/ if(p==’’) k=0; /**********found**********/ *(p)=toupper(*(p-1)) else k=1; main() char chrstr[64]; int d; printf("\nPlease enter an English sentence within 63 letters:"); gets(chrstr); d=strlen(chrstr); chrstr[d]=’’; chrstr[d+1]=0; printf("\n\nBefore changing:\n %s",chrstr); fun(chrstr); printf("\nAfter changing:\n%s",chrstr);
查看答案
搜索结果不匹配?点我反馈
更多问题