-
variable
I was trying to get my program to work the following way from the terminal (command prompt):
a.out 20 < document.doc
where the value "20" (or whatever is typed) is used as a variable in the compiled program's a.out file (program.cpp). I've tried a bunch of different ways to no avail... Help?
-
I don't think that makes any sense as you have it typed. You have a compiled program, yes? Does it take a command-line argument? If so, just type it: "a.out 20". If it doesn't take a command-line argument, then you've already lost ... unless it takes input from the user, in which case you need a file that says 20 in it that you can use to redirect (although just waiting to type "20" at the prompt doesn't seem like such a burden).
-
If the program is expecting an integer (on stdin), followed by a document (also on stdin), then do this:
Code:
( echo "20" ; cat document.doc ) | a.out
-
Salem's bash code is probably not what you want, in all likely hood.
How does the program read in 20 and the doc file?