Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct comp ***ccompx(const char name[])
- {
- struct comp **pv = (struct comp**) malloc(sizeof(struct comp*));
- if(!pv)
- {
- puts("\nRicerca interrotta");
- }
- pv[0] = comps;
- struct comp ***point;
- struct comp *p = (struct comp*)malloc(sizeof(struct comp));
- if(!p)
- {
- puts("\nRicerca interrotta");
- }
- int s = 1;
- for(p = comps; p; p = p->n)
- {
- if(strstr(p->name, name))
- {
- pv = (struct comp **) realloc(pv, sizeof(struct comp*) * (s + 1));
- if(!pv)
- {
- puts("\nRicerca non completata");
- goto ret;
- }
- point = &pv;
- (*point)[s] = p;
- s++;
- }
- }
- if(--s == 0)
- {
- free(point);
- point = 0;
- return point;
- }
- (*point)[0]->code = s;
- ret:
- return point;
- }
- int main()
- {
- struct comp ***pv = ccompx(name);
- if(pv)
- {
- int e = 0;
- for(; (*pv)[0]->code > e++;)
- {
- printf("\nCodice del componente: %d\n", (*pv)[e + 1]->code);
- printf("Nome del componente: %s\n", (*pv)[e + 1]->name);
- printf("Descrizione del componente: %s\n", (*pv)[e + 1]->des);
- printf("Disponibilita' del componente: %d\n\n", (*pv)[e + 1]->disp);
- }
- }
- }
Add Comment
Please, Sign In to add comment