linux下sleep函数的头文件
windows下的Sleep函数,首字母为大写,声明在windows.h头文件中,其参数usigned long类型,为毫秒数,即Sleep(1)为睡眠1毫秒。
linux下的sleep函数,首字母为小写,声明在unistd.h头文件中,其参数为秒数,即sleep(1)为睡眠1秒
加上#include<unistd.h>
fopen打开失败,返回一个空指针
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h> //gcc使用strerror(errno)需要引用
int main()
{
FILE *pf = fopen("test.txt","w");
if(pf == NULL)
{
printf("%s\n",strerror(errno));
}
else
{
//使用
printf("sucess\n");
}
//关闭文件
fclose(pf);
pf = NULL;
return 0;
}
fputs(char *,int,filestream*);
puts() 会打印\n
写:
读: