Hi all
Here is the situation:
I need a program that reads information from stdin and for example write it to stdout (the second part is not exactly the same but it's not important right now
). And that's what I wrote:
#include <stdio.h>
main()
{
char *str;
while (1)
{
if (fgets(str,124,stdin)!=NULL
{
printf("->%s\n",str);
}
}
}
and when I run: tail xxx.txt | ./a.out
I'm getting segmentation fault. I just hate this error
Can anyone tell me where the problem is
Thanks in advance
Here is the situation:
I need a program that reads information from stdin and for example write it to stdout (the second part is not exactly the same but it's not important right now
#include <stdio.h>
main()
{
char *str;
while (1)
{
if (fgets(str,124,stdin)!=NULL
{
printf("->%s\n",str);
}
}
}
and when I run: tail xxx.txt | ./a.out
I'm getting segmentation fault. I just hate this error
Can anyone tell me where the problem is
Thanks in advance