-3

I see this in a code challenge before and was wondering if this was the same as passing a parameter to a program?

Echo “string”| program.c


S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
avan989
  • 317
  • 1
  • 5
  • 12

1 Answers1

3

The shown code will probably not work at all, because program.c, if named according to the habits of practically any programmer, will be the pure C-code file, the "human readable" form of a program.
To use this in any way as an executable, you first need to build it (compile and link). The result it usually an executable file called program (or program.exe on Windows).
That file can be called similarly to the shown code

echo "string" | program

Which makes the string available via the diverse input functions ( https://en.cppreference.com/w/c/io ) and the standard input.

For accessing it as a parameter (using the parameters to main, function, usually named argc and argv; e.g. https://stackoverflow.com/a/47536091/7733418 ), you'd have to call the program like

program "string"
Yunnosch
  • 26,130
  • 9
  • 42
  • 54