I've wrote a small C program, which takes 3 integers as arguments. If I am running it like this: myapp 1 2 3 runs fine, argc shows correctly 4, but if I do: echo 1 2 3 | myapp, argc shows just 1.
The relevant part of the C code is:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
printf("Entered: %i\n", argc);
if ( argc < 4)
{
printf("You must enter 3 integers as command line arguments!\n");
exit(1);
}
}
What is wrong with this?