It is currently Sun Jan 21, 2018 2:42 pm Advanced search

Redirected stdin in vanilla C?

Code won't compile? Found a bug? Post here!

Redirected stdin in vanilla C?

Postby Demerzel » Tue Nov 09, 2010 7:34 pm

I was hoping one of you <20 other people doing plain C could share your stdin code - I'm hitting some kind of weird issue with redirected stdin only where the pipe breaks or something - works perfectly fine when I'm typing to it but piping/redirecting breaks it, no matter what I use in stdio and I've spent hours and hours on google now!

I can fix it in windows by using GetStdHandle etc but I am not familiar with linux and really don't want to go to virtualboxing. So please please help me out if any of you even read this!
Demerzel
Colonel
 
Posts: 72
Joined: Sat Oct 02, 2010 6:06 am
Location: themendios at gee mail

Re: Redirected stdin in vanilla C?

Postby Demerzel » Wed Nov 10, 2010 9:15 pm

Well, after way too much effort I got it.

Problem is the halting stdin/stdout apparently makes it temporarily unavailable as a FILE* or something, only thing I could do is use ONLY functions that do not have to specify stdin/stdout, namely I now have a getchar() loop and my output is a putchar() loop follow by fflush.

Just an FYI for anybody with the same problem!
Demerzel
Colonel
 
Posts: 72
Joined: Sat Oct 02, 2010 6:06 am
Location: themendios at gee mail


Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 3 guests

cron