file handling with fopen() and fclose()



Help!

I'm in the process of developing an app. using gtk1.2 that requires the
user to login, and thus needs to read /etc/shadow to get username and
password info.

Problem is, I've tried doing it with something like

fp=fopen("/etc/shadow");
if(fp==NULL)
	fatal_error("cannot open file");
fclose(fp);
showmessage("login processing done");

<fatal_error> and <showmessage> are my own functions that work ok - i
have tested them, so they're not at issue here.

Problem is that the code never gets to either the showmessage() or
fatalerror() calls.  I need to do line-by-line text processing with fp,
so a stream-based approach that lets me use fgets() is better.

Is there a workaround?  Has anyone run into similar problems?  I have
very similar code working fine in an ncurses-based version, but this is
really bugging me.

TIA,

John Breen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]