编写程序,将一个字符串中的所有小写字母转换为大写字母,其余不变,用指针法

#include
#include
int main()
{char a[100],*p=a;
gets(p);
for(;*p!='\0';p++)
if(*p>='a'&&*p<='z')
*p=*p-32;
puts(p);
}

因为你的for循环结束后,p是指向字符串尾的(也就是'\0'),所以你puts(p)没有结果,你应该puts(a)才对

 #include<stdio.h>
#include<string.h>
int main()
{
    char a[100], *p = a;
    gets(p);
    for (; *p != '\0'; p++)
    if (*p >= 'a'&&*p <= 'z')
        *p = *p - 32;
    puts(a);
}

toUpperCase