Linux提供了一个特殊的设备 /dev/tty ,该设备始终是指向当前终端或者当前的登录会话。

FILE* output = fopen("/dev/tty", "w");

 

//向终端写入字符串

fprintf(output, "%s\n", "world");

 

 

FILE* input = fopen("/dev/tty", "r");

 

//从终端读取单个字符

char c = fgetc(input);

相关文章:

  • 2021-06-16
  • 2021-10-07
  • 2021-12-25
  • 2021-06-21
  • 2021-05-06
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-12-30
  • 2022-01-23
相关资源
相似解决方案