Jump to content
  • Advertisement
Sign in to follow this  
ace84_84

C - STDIN, STDOUT

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a program where i dup2 the STDIN (0) with my file descriptor number, then i do the same for the STDOUT (1). So when i write i am actually writing to the stdout. my problem is i am having trouble reading the data from the stdin. will a simple scanf do the trick or will i need to use a system call like fgets to get the data????

Share this post


Link to post
Share on other sites
Advertisement
fgets and scanf are both part of the same set of stdio functions. You could use either depending on what you want to do. What is the problem you are having?

Share this post


Link to post
Share on other sites
In order to use a file descriptor with the fprintf/fscanf family of functions, you'll have to associate the descriptor with a stream. Have a look at the fdopen function for that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!