#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void fun(char *ss)
{ int i, aa[81];
for(i=0;i<81;i++)
if(i%2==1)
if(aa[i]>'a'||aa[i]<'z')
*ss=aa[i]-32;
return *ss;
}
void main()
{
FILE *wf;
char tt[81],s[81]="abc4Efg";
system("CLS");
printf("\nPlease enter an string within 80 characters:\n");
gets(tt);
printf("\n\nAfter changing, the string\n %s",tt);
fun(tt);
printf("\nbecomes\n %s\n",tt);
wf=fopen("out.dat","w");
fun(s);
fprintf (wf,"%s",s);
fclose(wf);
}
本题要求将奇数位上的小写字母变成大写其余不变。如abc4EfG变成aBc4EFG
粗体是我编写的程序,编译连接均没有错误,为什么运行时得不到正确答案。(不用指针来做)