25、给定程序MODI1.C中 fun 函数的功能是:将p所指字符串中每个单词的最后一个字母改成大写。(这里的“单词”是指由空格隔开的字符串)。
例如, 若输入
"I am a student to take the examination.",
则应输出 "I aM A studenT tO takE thE examination."。
请修改程序中的错误之处, 使它能得出正确的结果。
注意: 不要改动 main 函数, 不得删行, 也不得更改程序的结构!
#include #include #include void fun( char *p )
{
int k = 0;
for( ; *p; p++ )
if( k )
{
/**********found***********/
if( p == ' ' )
{
k = 0;
/**********found***********/
* (p-1) = 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);
}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|