C getchar putchar and break when press escape key

2022/8/7 23:28:29

本文主要是介绍C getchar putchar and break when press escape key,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

//main.c
#include <stdio.h>

void getPutChar();

main()
{
   getPutChar();
}

void getPutChar()
{
    char c;
    while((int)(c=getchar())!=27)
    {
        putchar(c);
    } 
}

Compile

cc main.c -o h1

Run

./h1

 

 

 

 

//main.c

#include <stdio.h>


main()
{
   getPutChar();
}

void getPutChar()
{
    char c;
    while((c=getchar())!=27)
    {
        putchar(c);
    } 
}

 

Compile

cc main.c -o h1

Run

./h1

 

 

 

main()
{
   printChar();
}

void printChar()
{
    int c;
    c=getchar();
    while(c!=27)
    {
        putchar(c);
        c=getchar();
    }
}

 



这篇关于C getchar putchar and break when press escape key的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程