Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C, parsing /etc/passwd, getting userids


ghost's Avatar
0 0

Hello, I've been working on creating a linux shell. I figured that I should have it customizable like other shells. So, I figured that I should put a customizable file in the home directory. I am going to use getuid() to get the current user id and then find a matching user id in /etc/passwd and take the corresponding home directory. However, I don't seem to be parsing correctly. This is what I have: http://pastebin.com/m4ce56ad5. That's the code and what happens when I run it. Does anyone have any ideas? I can't seem to find any logic in it at all.

Edit: Nevermind, I got it. Using fscanf with %s sucks, had to go through with fgetc(f);.