[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Problem in one program...
- From: FX <fabricio jampa com br>
- To: gtk-app-devel-list redhat com
- Subject: Problem in one program...
- Date: Sun, 08 Aug 1999 11:21:01 -0300
Hi all!
I written this program, but not fuction correct! Why? This program read
entries in /etc/passwd and add in on GList *list.
Compiling this program and look why don't function correct.
#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
#include <sys/types.h>
#include <glib.h>
GList *list = NULL;
GList *listrunner = NULL;
int gsa_user_read_data(void)
{
struct passwd *user;
char tecla;
int i;
for(i=0; i < 5; i++) {
user = (gpointer) g_malloc (sizeof(struct passwd));
user = getpwent ();
list = g_list_append (list, (gpointer)user);
printf("\nUser: %s\n", user->pw_name);
printf("Home-Dir: %s\n", user->pw_dir);
printf("Shell: %s\n", user->pw_shell);
tecla = getchar ();
}
}
int gsa_user_show_data (void)
{
struct passwd *show;
char tecla;
listrunner = g_list_first (list);
system("clear");
while (listrunner) {
show = (gpointer) g_malloc (sizeof(struct passwd));
show = (struct passwd*)listrunner->data;
printf("Tamanho da lista: %d\n", g_list_length (list));
printf("\nUser: %s\n", show->pw_name);
printf("Home-Dir: %s\n", show->pw_dir);
printf("Shell: %s\n", show->pw_shell);
tecla = getchar ();
listrunner = g_list_next (listrunner);
}
}
int main()
{
system ("clear");
gsa_user_show_data ();
gsa_user_read_data ();
}
Thanks,
Fabricio [FX]
P.S: Sorry my bad English! :P
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]