I'm not sure which is the best way to read The following text file which was generated in the following way:
Struct
int nro_orden;
char desc[30];
int cantidad;
fprintf(pf,"%03d%-30s%03d\n",pedido[i].nro_orden,pedido[i].desc,pedido[i].cantidad);
001Alpargatas 050
002Zapatillas Nike 020
003Calzones 040
004Medias levis 025
005Chomba Adidas 030
I am reading the file in the following way:
char string[38];
while(fgets(string,sizeof(string),pf))
{
sscanf(string,"%03d%29[^\n]%03d",&pedido[i].nro_orden,pedido[i].desc,&pedido[i].cantidad);
}
But the problem is that I request [i] .desc I have the description + the blanks. I do not know if there is a way to get this description without them or if I have to get them after obtaining them.
Thank you very much for your time