edit: cribbio ho dimenticato il tag
questa è la parte del codice:
codice:
typedef struct
{
char cmd[100];
int pid;
} t_figlio;
#define MAX_FIGLI 100
t_figlio figli[MAX_FIGLI];
int tot=0;
void update_figli(int pid,char * arg){
int i=0;
while(i<MAX_FIGLI && figli[i]!=pid) i++;
strcpy(figli[i].cmd,arg);
}
void init_figli(){
int i;
for(i=0;i<MAX_FIGLI;i++)
figli[i].pid=0;
}
void add_figlio(int pid){
int i;
i=0;
while(i<MAX_FIGLI && figli[i]!=0) i++;
figli[i].pid=pid;
tot=i;
}
void rem_figlio(int pid){
int i,k;
i=0;
while(i<MAX_FIGLI && figli[i]!=pid) i++;
if (i==tot) exit(-1);
for(k=i;k<tot;k++) {
figli[k].pid=figli[k+1].pid;
strcpy(figli[k].cmd,figli[k].cmd)
}
tot--;
}
ora, quando compilo dice:
codice:
stefano@ubuntu:~/shell$ make
figli.c:13: error: syntax error before ‘figli’
figli.c:13: warning: data definition has no type or storage class
figli.c: In function ‘update_figli’:
figli.c:19: error: request for member ‘cmd’ in something not a structure or union
figli.c: In function ‘init_figli’:
figli.c:25: error: request for member ‘pid’ in something not a structure or union
figli.c: In function ‘add_figlio’:
figli.c:32: error: request for member ‘pid’ in something not a structure or union
figli.c: In function ‘rem_figlio’:
figli.c:42: error: request for member ‘pid’ in something not a structure or union
figli.c:42: error: request for member ‘pid’ in something not a structure or union
figli.c:43: error: request for member ‘cmd’ in something not a structure or union
figli.c:43: error: request for member ‘cmd’ in something not a structure or union
figli.c:44: error: syntax error before ‘}’ token
figli.c: In function ‘jobs’:
figli.c:54: error: request for member ‘pid’ in something not a structure or union
figli.c:60: error: request for member ‘cmd’ in something not a structure or union
figli.c:62: error: request for member ‘cmd’ in something not a structure or union
figli.c:69: error: request for member ‘cmd’ in something not a structure or union
figli.c:71: error: request for member ‘cmd’ in something not a structure or union
make: *** [figli.o] Error 1
che diavolo vuole?