下列给定程序的功能是:读入一个英文文本行,将其中每个单词的第一个字母改成大写,然后输出此文本行(这里”单词”是指由空格隔开的字符串)。例如,若输入"I am a student to takethe examination",则应输出"I Am A Stu

admin2020-10-26  19

问题 下列给定程序的功能是:读入一个英文文本行,将其中每个单词的第一个字母改成大写,然后输出此文本行(这里”单词”是指由空格隔开的字符串)。例如,若输入"I am a student to takethe examination",则应输出"I Am A Student To TakeThe Examination"。
请改正程序中的错误,使程序能得出正确的结果。
注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
1  #include<stdlib.h>
2  #include<string.h>
3  #include<conio.h>
4  #include<ctype.h>
5  #include<stdio.h>
6  #include<string.h>
7  /*********found*********/
8  void upfst(char P)
9  {
10    int k=0;
11    for(;*P;P++)
12      if(k)
13       {
14      if(*P==’’)
15       k=0;
16       }
17     else
18      {
19         if(*P!=’’)
20         {
21            k=1;
22            *P=toupper(*P);
23         }
24      }
25   }
26   void main()
27   {
28      char chrstr[81]j
29      System("CLS");
30      printf("\nPlease enter an English text;lihe:");
31      gets(chrstr);
32      printf("\nBofore changing:\n%s",chrstr);
33      upfst(chrstr);
34      printf("\nAfter changing:\n%s\n",chrstr);
35   }

选项

答案void upfst(char*p)

解析 主函数中fun函数的调用方式说明函数fun的参数应为指针类型。
转载请注明原文地址:https://kaotiyun.com/show/Ot3p777K
0

最新回复(0)