用fgets
例如:
FILE * hp = fopen("c:\\boot.ini","r");
char * s = new char [255];
memset(s,0,255);
fgets(s,255,hp);
fclose(hp);
delete [] s;
不过fgets 第二个参数限制了读取的长度
The function stops reading when it reads either n - 1 characters or a newline character whichever comes first.
这个讲的就是假如没有碰到换行符就读完了n - 1 个字节,则只读取n-1个字节
假如碰到了换行符,则就读取到换行符之前的一行字符