⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readline.c

📁 nachos操作系统框架
💻 C
字号:
#include "stdio.h"#include "stdlib.h"void readline(char *s, int maxlength) {  int i = 0;  while (1) {    char c = getch();    /* if end of line, finish up */    if (c == '\n') {      putchar('\n');      s[i] = 0;      return;    }    /* else if backspace... */    else if (c == '\b') {      /* if nothing to delete, beep */      if (i == 0) {	beep();      }      /* else delete it */      else {	printf("\b \b");	i--;      }    }    /* else if bad character or no room for more, beep */    else if (c < 0x20 || i+1 == maxlength) {      beep();    }    /* else add the character */    else {      s[i++] = c;      putchar(c);    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -