Code:
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
if (argc < 2)
{
printf("no \n");
printf("see --> %s , you gimme nothing, nothing I say! NOHING!!!! \n"
"How do you expect me to work with nothing????\n", argv[1]);
exit(1);
}
char c;
while ((c=getchar()) !=EOF)
{
putchar(c);
}
return 0;
}
Code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char **argv)
{
if (argc < 2)
{
printf("no \n");
printf("see --> %s , you gimme nothing, nothing I say! NOHING!!!! \n"
"How do you expect me to work with nothing????\n", argv[1]);
exit(1);
}
char *ch;
if (fgets(argv[1], 10, stdin) == NULL)
exit(1);
ch = fgets(argv[1], 10, stdin);
fputs(ch, stdout);
printf("\n");
return 0;
}
that does something too.
maybe you'll see a difference in how to get stuff off the line, and put it back onto the line.