小编Ins*_*per的帖子

谁能检查程序并告诉我如何才能获得正确的输出?

#include <stdio.h>
#include <stdlib.h>

int main()

{

    char a,b;

    printf("enter the firstkeyword \n");
    a = getchar();
    printf("enter your second keyword \n");
    b = getchar();

    if(a>b)
    {
    printf("it is '%c' greater than '%c' as i expected \n",a,b);
    }
    else if (b>a)
    {
    printf("here'%c'is greater than '%c' \n",b,a);
    }
    else
    {
    printf("dont type the same character twice in next session \n");
    }
    return(0);

}
Run Code Online (Sandbox Code Playgroud)

在编译程序之后,o/p是:

输入第一个关键字

我输入'$'并使用ctrl + z来eof并'enter'继续该程序.但即使没有输入第二个关键字,编译器也会将输出打印为

输入第二个关键字

正如我所料,它比' - >'更大'.'

任何人都可以帮助这个计划吗?

对不起,如果有任何语法或短语错误.

c compilation getchar output

2
推荐指数
1
解决办法
155
查看次数

标签 统计

c ×1

compilation ×1

getchar ×1

output ×1