1、getline(char s[], int lim)
调用结果:往参数数组中读入字符直到换行(即:读取一行)
返回值:参数数组所读入的字符串长度
在《c程序设计语言中》里使用频率特别高。
version 1:
int getline(char s[], int lim) { int c, i; for(i = 0; i < lim - 1 && (c = getchar()) != EOF && c != ' '; ++ i) s[i] = c; if(c == ' '){ s[i] = c; ++ i; } s[i] = '