Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 从文本文件读取目录和文件名_C_File - Fatal编程技术网

C 从文本文件读取目录和文件名

C 从文本文件读取目录和文件名,c,file,C,File,我有一个文本文件,由文本文件的名称和目录组成。例如:在名为“fileoutput.txt”的文件中,我有以下内容: Desktop/textFinder/text.txt Desktop/textFinder/text1.txt 现在我正在尝试读取文件“fileoutput.txt”,并在text.txt和text1.txt上进行处理。我使用了FILE*fp=fopen(“fileoutput.txt”,“r”)``readFindFile(fp)在main中,我使用了以下代码: void

我有一个文本文件,由文本文件的名称和目录组成。例如:在名为“fileoutput.txt”的文件中,我有以下内容:

Desktop/textFinder/text.txt

Desktop/textFinder/text1.txt
现在我正在尝试读取文件“fileoutput.txt”,并在text.txt和text1.txt上进行处理。我使用了
FILE*fp=fopen(“fileoutput.txt”,“r”)``readFindFile(fp)在main中,我使用了以下代码:

void readFindFile(FILE *fp)

{

int count = 1;
char buff[255];

while(fscanf(fp,"%s",buff)==1 )

{

FILE *fp1 = fopen(buff, "r");

printf("The file %s will be processed!\n", buff);
if( fp1 == NULL )

{

perror("Error while opening the file.\n");

exit(EXIT_FAILURE);

}

RW(fp1);// for doing process on  text.txt and text1.txt

}

fclose(fp);

}
当程序读取fileoutput.txt时,它无法处理Desktop/textFinder/text.txte,我给出了这个错误:不是这样的文件或目录


你能帮我解决这个问题吗?

尝试输入文件列表的完整路径。 注意:对于windows,它将如下所示:
C:\Users\(user)\Desktop\textFinder\text1.txt

对于Linux:


/home/(user)/Desktop/textFinder/text1.txt

您的工作目录错误或相对路径与实际文件不对应。发生错误时,buff
的内容是什么?当前目录是否有名为“Desktop”的子目录?