开发者

File I/O in c++ and linux command line redirect

开发者 https://www.devze.com 2023-04-06 19:05 出处:网络
I\'ve got a program that accepts a text file with a map on it, then finds the shortest path and outputs that to another file.

I've got a program that accepts a text file with a map on it, then finds the shortest path and outputs that to another file.

it needs to work like this

./pathFinder -开发者_StackOverflowarg < inputMap.txt > outputMap.txt

My question is, with this input, what would get filled into argv[] and argc (do the redirects count as arguments), and also should I use file streams or just cin/cout... or maybe something else. Thanks.


argc will be 2, and argv[1] will point to "-arg".

Redirects will simply appear on stdin and stdout (wrapped by std::cin and std::cout).


argv will contain {"./pathFinder", "-arg"}


The redirect will not count as arguments. Just use cin/cout will be fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号