编写一个函数fun,它的功能是:将ss所指字符串中所有下标是奇数位置上的字母转换为大写(若该位置上不是字母,则不转换)。主函数不变。。
#include <conio.h>
#include <stdio.h>
#include <string.h>
void fun ( char *ss)
{ int i=1;
char *rr=ss;
while((*rr)!='\0')
{ if(rr[i]>='a'&&rr[i]<='z')
rr[i]=rr[i]-32;
i+=2;
}
}
main( )
{
char tt[81];
FILE *out;
printf("\n Please enter an string within 80 characters:\n");
gets( tt );
printf("\n\nAfter changing, the string\n %s\n", tt );
fun( tt );
printf( "\nbecomes \n %s\n", tt );
out=fopen ("out.dat", "w");
strcpy(tt, "Hello boys and girls!");
fun(tt);
fprintf ( out, "%s\n", tt );
fclose (out );
getch;
}