There are very little information in the question to be able to give a proper answer. One option is fixing getdatafromstdin
to get a FILE *
as argument instead of assuming stdin
, so you can give a FILE *
that you want. Another option is to divide the program into two parts. One that generates the input data and the other that uses getdatafromstdin
and then pipe the two.
One easy to add option however if you don't want to do the others is a bit of cheating. You can write the data you want to feed to stdin
to a file and then use freopen
to reopen stdin
to read from that file. Then calling your getdatafromstdin
would read from that file.
If you pipe in stdin
or freopen
it, making it use the terminal later is not trivial. So I would recommend the first option (fix the getdatafromstdin
function to get a FILE *
parameter), but my guess is that it's not your own API.