简体   繁体   中英

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

../input1.txt ../output1.txt

../input2.txt ../output2.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.

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. eg// under a given.txt

../input.txt

../output.txt

but these aren't what I am searching for

Thanks for your help.

假设路径中不包含空格,则可以在字符串上拆分字符串(使用字符串操作库),这将返回两个标记:第一个是读取路径,第二个是写入路径。

您可以尝试将fscanf()函数与以下格式的字符串"%s %s"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM