[英]C programming - read 2 different directories in the same line from a text file
I am trying to read two different file directories from a single line in a text file. 我正在尝试从文本文件的一行中读取两个不同的文件目录。
eg// under a given.txt file, there are multiple lines of input directory and output directory with a "space" between them in one line 例如,在给定的.txt文件中,输入目录和输出目录存在多行,并且它们之间的一行之间有一个“空格”
../input1.txt ../output1.txt ../input1.txt ../output1.txt
../input2.txt ../output2.txt ../input2.txt ../output2.txt
../input3.txt ../output3.txt ../input3.txt ../output3.txt
..... etc. so my goal would be loop reading line by line, fetch input#.txt, manipulate it, then send to output#.txt. .....等等,所以我的目标是逐行循环读取,获取输入#.txt,对其进行操作,然后发送至输出#.txt。
My question is, how to separately read directories in each line with a space between them? 我的问题是,如何分别读取每行中的目录并在它们之间留有空格?
I have tried to google the topic, but all of them are either regarding command prompt argc & argv or reading line by line with one directory in each line. 我试图用谷歌搜索这个话题,但是所有这些都是关于命令提示符argc和argv的,或者是一行一行地逐行读取目录。 eg// under a given.txt
例如//在给定的.txt下
../input.txt ../input.txt
../output.txt ../output.txt
but these aren't what I am searching for 但是这些不是我要寻找的
Thanks for your help. 谢谢你的帮助。
假设路径中不包含空格,则可以在字符串上拆分字符串(使用字符串操作库),这将返回两个标记:第一个是读取路径,第二个是写入路径。
您可以尝试将fscanf()
函数与以下格式的字符串"%s %s"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.