He hecho el siguiente programa, una lista que va almacenando productos y me da error con windows despues del compilar:
#include <stdio.h>
#include <stdlib.h>
typedef struct stNode {
char nomFruita[50];
float preuPerQuilo;
int quantitat;
struct stNode *seg;
}tNode;
typedef struct stLlista{
tNode *llista;
}tLlista;
void OmplirStock (tLlista *a)
{
int x;
int i;
tNode *b;
tNode *actual;
b= (tNode*) malloc (sizeof (tNode));
if (b==NULL){
printf ("ERROR");
exit(-1);}
printf ("Quants productes vol demanar al proveidor?\n");
scanf ("%d", &x);
actual = a->llista;
i=1;
while (i<=x){
printf ("Introdueix el nom del producte\n");
scanf ("%s", &b->nomFruita[50]);
printf ("Introdueix el preu del producte\n");
scanf ("%f", &b->preuPerQuilo);
printf ("Introdueix la quantitat del producte\n");
scanf ("%d", &b->quantitat);
if (actual == NULL){
b->seg = a->llista;
a->llista = b;
}else{
b->seg = actual->seg;
actual = b;
}
i = i+1;
}
}
int main () {
tLlista llista;
OmplirStock (&llista);
system ("PAUSE");
return (0);
}
Muchas gracias