?? lineholder.c
字號(hào):
/* lineholder.c- Bob Wilson */#include <stdio.h>#include <string.h>#include "lineholder.h"void *malloc(int);void free(void*);static char *lines[MAXLINE];static int first, last, end, wrapped;void init_lineholder(int nlines){ if (nlines > MAXLINE) nlines = MAXLINE; first = last = 0; end = nlines-1; wrapped = 0;}void insert_line(char *line){ if (lines[last] != NULL) free((void *) lines[last]); if ((lines[last] = (char * ) malloc(strlen(line) + 1)) != NULL) strcpy(lines[last], line); last++; if (last > end) { last = 0; wrapped = 1; } if (wrapped) first = (++first > end)? 0 : first;}void print_lines(void){ int i; for (i = 0; i <= end; i++) { if (lines[first] != NULL) { printf("%s", lines[first]); free ((void *) lines[first]); lines[first] = NULL; } first = (++first > end)? 0 : first; }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -