For example, say I have a program like this:
file1.c is
#include <stdio.h>
int main(int argc, char **argv) {
if (argc != 2) {
printf("one file only\n");
return (1);
} else {
for (size_t i = 0; argv[1][i] != '\0'; i++) {
if(argv[1][i] != 'a') {
putchar(argv[1][i]);
}
}
putchar('\n');
}
}
Above is a simple problem that iterates the input of argv[1] and removes every 'a'.
For example
$ gcc -Wall file1.c
$ ./a.out abcd
bcd
Is it possible to tweak this code to make piping work? As in,
$ echo abcd | ./a.out
bcd