when I put a no output program on the left of pipe, such as:
// program a
int main() {
char s[255];
scanf("%s", s);
return 0;
}
and a program with input & output on the right:
// program b
int main() {
char s[255];
scanf("%s", s);
for(char *c = s; *(c) != '\0'; c++) printf("%d ", *c);
return 0;
}
when I try to connect them with pipe:
$ ./a | ./b
No matter what the input is, I always get two ascii codes: 64
& 3
in my computer, Even though I know that 'a' has no output.
I want to know if this is because of my program, or because of the shell, or because of the pipeline, or something else...