Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Reading from stdin with C

Name: Anonymous 2009-05-20 16:45

Okay, it's not as easy as you think.
I want to do something like this:

ls -lh | ./myProg


Now, how can I read the data from stdin in my program?
I tried fgets, getline and fscanf. None of those work - they either crash the program or just get into the interactive mode (where the program's waiting for user input) which I do not want.

Halp.

Name: Anonymous 2009-05-20 16:46

haha c

Name: Anonymous 2009-05-20 16:47

Install Linux

Name: Anonymous 2009-05-20 16:50

HA HA HA OH WOW

Name: Anonymous 2009-05-20 16:51

Okay, it's not as easy as you think.
It's exactly as easy as you think.

Name: Anonymous 2009-05-20 16:52

Why on WHY did I know that this would happen?

Name: Anonymous 2009-05-20 16:52

pass - as an argument, gcc will take care of the rest for you

Name: Anonymous 2009-05-20 17:17

>>5
Okay, it actually was.
My Google-fu was weak, but I have learned a lot today.

So long and thanks for all the fish.

Name: Anonymous 2009-05-20 18:26

>>1
man man

Name: Anonymous 2011-02-04 16:57

Name: Anonymous 2011-02-04 19:55


Don't change these.
Name: Email:
Entire Thread Thread List