imagergod 发表于 2021-1-22 19:23:12

C语言

#include <bits/stdc++.h>
using namespace std;
main()
{
        int i=0;
        char c;
        while(1)
        {
                c='\0';
                while(c!=13&&c!=27)
                {
                        c=getch();
                        printf("%c\n",c);
                }
                if(c==27)
                        break;
                i++;
                printf("The No. is%d\n",i);
        }
        printf("The end");
}
为什么getch()会报错,我看着视频打的

jackz007 发表于 2021-1-22 20:43:52

#include <stdio.h>
#include <conio.h>       // 使用 getch() 、putch() 必须包含此头文件

int main(void)
{
      int i = 0                     ;
      char c                        ;
      c = getch() ;
      while(c != 13 && c != 27) {
                putch(c)                ;
                i ++                  ;
                c = getch()             ;
      }
      putch('\n')                     ;
      printf("The No. is : %d\n" , i) ;      
      printf("The end")               ;
}

imagergod 发表于 2021-1-23 17:33:10

jackz007 发表于 2021-1-22 20:43


谢谢
页: [1]
查看完整版本: C语言