Skip to main content
gamedev.net
🔒 Locked

C - STDIN, STDOUT

Started by ace84_84 Nov 29, 2005 at 9:08 PM 1 replies 1k views
Original Post
ace84_84
ace84_84
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????
JohnBolton
JohnBolton
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?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Shadowdancer
Shadowdancer
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.