hello all, I have been given the task of creating a passwd program that uses the 'struct passwd' structure, in order to 1) read to first ten values of /etc/passwd file and display the userID and the userName. 2) Also once this is done, modify the program, so that it will store the first ten entry's from the password file into an array of structures. 3)print out the usernames and UID's this time using the array.
I have overcome the first part of the question (1) by using this:
For part two, do need to declare another structure before main, with a character pointer for the username value and an int for the UID. like so:
struct passwd *pwd;
printf("%s %d \n", (*pwd).pw_name,(*pwd).pw_uid);
Or do i have to use the struct passwd *ptr strucutre somehow? Need help on how to store the UID and Username into an array of structures please.
typedef struct store