You'll want to look up "C stdin" or "C++ stdin". From the bash man page when you're using a pipe you're redirecting stdout of one program to stdin of another. In a program the three most common file descriptors are stdout (file descriptor 1), stdin (file descriptor 0), and stderr (file descriptor 2). However, a program can have up to 9 file descriptors to manipulate input and output.
See
Redirection in bash for a more thorough description about that topic.