编程排错
#include <conio.h>
#include <stdio.h>
void fun(char *ss)
{
int n =0 , i ;
while ( *ss )
{
n++ ;
ss++ ;
}
for ( i = 1 ; i < n ; i+=2 )
if ( ss[i] >= 'a' && ss[i] <= 'z' )
ss[i] = ss[i] -32 ;
}
void main( void )
{
char tt[51];
clrscr();
printf("\nPlease enter an character string within 50 characters:\n" );
gets( tt );
printf("\n\nAfter changing, the string\n %s", tt );
fun(tt) ;
printf( "\nbecomes\n %s", tt );
}
将字符串ss中所有下标为奇数上的字母转换为大写,若该位置上不是字母,而不转换。