You may have overcomplicated the problem. If you want a program to read a list items piped to it...
#define MAXLINELEN 1000
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[]) {
char line[MAXLINELEN];
FILE *fpin;
fpin=stdin;
while(fgets(line,MAXLINELEN,fpin)!=NULL) printf("%s",line);
}
... you can then parse the items on each line using strtok(), or if you use "ls -1", each list item is on a unique line anyway.
Hope this helps.