Emmanuel Delahaye ha scritto:
[color=blue]
> Do you meant:[/color]
[color=blue]
> string1<blank>string2<EOL>
> string3<blank>string4<EOL>[/color]
[color=blue]
> ?[/color]
exactly, thanks for replying
[color=blue]
> You can use each line with fgets() and then extract the strings with
> sscanf() and "%s %s". Make sure that sscanf() returns 2.[/color]
I was trying with fscanf, now I tried the way u suggested with no results:
char *array1[2], *array2[2],buff[512];
FILE *f;
i=0;
do {
if ( fgets(buff,sizeof(buff),f)==NULL ) perror("fgets");
if ( (i = sscanf(buff,"%s %s",array1[i],array2[i])) printf("%d\n",i);
i++;
}while(i<2);
it opens the file correctly but then the sscanf returns 0, it gets stuck
during the second iteraction of the do-while
I'm sure I'm doing some really stupid mistakes, I'm not experienced,I've
been coding the whole day and this should be working tomorrow
thanks a lot
--
questo articolo e` stato inviato via web dal servizio gratuito
http://www.newsland.it/news segnala gli abusi ad
abuse@newsland.it