利用open()函数打开文件时,只能检测当前文件夹中是否有该文件,如果想要在其他地方查找应该怎么办呢?
加入绝对路径或者相对路径
#include<stdio.h>
#include<io.h>
#include<fcntl.h>
int main(void){
int fd=open("D:\\cyy\\a.txt",O_RDWR+O_CREAT);
if(fd==-1){
printf("can not open the file\n");
return 1;
}
printf("successful to open the file\n");
close(fd);
return 0;
}
啥叫想在其他地方查找?如果该文件夹里没有,搜索全盘????