2、下面的程序试图有如下运行结果:

来源:百度知道 编辑:UC知道 时间:2024/05/11 15:34:55
which style you want to :
Capital ( c ) or uncapital ( a ):c ↙
COMPUTER

Which sytle you want to :
Capital ( c ) or uncapital ( a ) : u↙
computer
请调试下面的程序,使其有如上执行结果。
#include <stdio.h>
main ()
{
char s*;
char c;
printf(“which style you want to :\n”);
printf(“capital ( c ) or uncapital(a):”);
c=getchar();
if(c=’c’)strcpy(s,”COMPUTER”);
else strcpy(s,”computer”);
put(s);
}
分析出错原因。

#include <stdio.h>
main ()
{
char *s;
char c;
printf("which style you want to :\n");
printf("capital ( c ) or uncapital(a):");
c=getchar();
if(c=='c')
s="COMPUTER";
else
s="computer";
puts(s);
getch();
}