Блог пользователя Mohamed_Saad62

Автор Mohamed_Saad62, история, 3 года назад, По-английски

If I have a Program.exe that takes input and print it.
If I want to run this program from the cmd I will go to its directory and write Program.exe (enter).
And what is going to happen a new line and waiting for the input.
But what if I want to give the input at the same line like that :

c:\Users\abc> Program.exe input
and that's it the program doesn't ask for input(as I gave it at the same line when I invoked the program) and print the output and terminate

I am working with c++.

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится -30 Проголосовать: не нравится

koi-sense-hai-is-baat-ki-1595528152 haha

»
3 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

I think if you want to give input at command line you have to use Command line arguements argv[] in c++

»
3 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

You are confused with standard in and argument variables. You can use char *argv[].
Read this

»
3 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

As a side note, if you want to pass input on the same line (e.g. for scripting), use echo input | program.exe. On Linux use <<<"input" ./program.