/**测试fgets(),fputs(),puts()
*/#define F_NAME "source"#include<stdio.h>intmain(){
FILE * fp =fopen(F_NAME,"r");char str[50],*p;while(1){
p =fgets(str,sizeof(str),fp);fputs(str,stdout);//这一步输出是带换行的。puts(str);
p =1;}return0;}
#include<stdio.h>#include<errno.h>intmain(){
errno =2;perror("i");return0;}
输出是:
>/home/seek/CLionProjects/learn/cmake-build-debug/learn i:> No suchfile or directory
> Process finished with exit code 0