c++ - Passing arguments with makefiles -


i have program needs open file, parse line line, , run code lines. have program doing want except has prompt target file. need file makefile instead.

the makefile line is:

$(path)/program.exe file.txt 

what i'm not sure how open file.txt in program.exe. way know open files in c++ is:

ifsream file; file.open(some_string_here) 

should using this: c-comm-line-strings? call argv, or there better way this?

edit question clarity: question have here "how use command line arguments?" answer supplied in comments r sahu

(i think know answer, work in unix , seem using windows, of follows may need adjustment.)

if i'm reading question right, can execute program on command line:

./program.exe 

it prompts filename, give "file.txt" , runs smoothly. try passing input through pipe:

echo file.txt | ./program.exe 

if works, can put in makefile:

echo file.txt | $(path)/program.exe 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -