#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <stdlib.h>
#else
#include <termios.h>
#include <unistd.h>
#endif
int press_key();
int main()
{
   press_key();
   return 0;
}

int press_key()
{
#ifdef _WIN32
   system("pause");
   return 0;
#else
   printf("Press any key to continue...\n");
   struct termios tm, tm_old;
   int fd = STDIN_FILENO,c;
   if (tcgetattr(fd, &tm) < 0)
   {
      return -1;
   }

   tm_old = tm;
   cfmakeraw(&tm);
   if (tcsetattr(fd, TCSANOW, &tm) < 0)
   {
      return -1;
   }
   c = fgetc(stdin);

   if (tcsetattr(fd,TCSANOW,&tm_old) < 0)
   {
      return -1;
   }
   return c;
#endif
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-01-10
  • 2022-12-23
  • 2021-07-29
  • 2022-01-15
  • 2021-06-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-07-12
相关资源
相似解决方案