In the find.c
there is the following code
for (size = 0; size < MAX; size++)
{
// wait for hay until EOF
printf("\nhaystack[%i] = ", size);
int straw = get_int(); // ??? get 2nd argument from ./generate (argv[1]); number random integers
if (straw == INT_MAX)
{
break;
}
// add hay to stack
haystack[size] = straw;
}
If I use this command ./generate 1000 50 | ./find 127
How it count to haystack[1000] =
? From where and how it takes 1000?
I suppose from int straw = get_int();
where get_int()
somehow takes 2nd argument from generate.c (argv[1])
; number random integers ) one by one ( int straw = get_int();
) and put it to haystack[size]. But I don't undersand how.