fgets与fscanf读入一行

char *fgets(char *s, int n, FILE *stream);

int fscanf(FILE *stream, char *format,[argument...]);

 

fgets读入最后的\n,而fscanf不读入。

所以在获得字符串长度是,int len = strlen(s)-1;//fgets对人的

或者int len = strlen(s);//fscanf 读入的

posted on 2012-04-22 12:03  wps712  阅读(3772)  评论(0编辑  收藏  举报

导航