Did you declare  your input and output streams?

******************************************************  
*  Van Sy                                            *
*  WORK: [EMAIL PROTECTED] (507)452-8932             *
*  HOME: [EMAIL PROTECTED] (507)452-4668  *
******************************************************  

On Mon, 14 Sep 1998, [ISO-8859-1] Torbj�rn Kristoffersen wrote:

> I want a function that reads a line from a file, separates
> the two variables (one string and one integer).
> (I am going to use those variables later)..
> 
> The code so far:
>  
> 
> void output_db()
> {
>    for(;;)
>    {
>       char name[60];
>       int  number;
>                   
>       if(!fgets(line, sizeof(line), fp))
>          break;
>                    
>       if(sscanf(line, "%s %d", name, &number) != 2)
>       {
>          fprintf(stderr, "error !\n");
>          continue;
>       }
>                               
>       fprintf(stdout, "%s %d", name, &number);
>    }
>                                       
>    fclose(fp);
> }
> 
> (*fp is global)
> 
> 
> But the result is : "error ! error !". 
> The file film.db is exactly two lines by the way.
> 
> The file format looks like this:
> 
> First blood 1982
> The shining 1980
> 
> 
> Torbj�rn Kristoffersen
> [EMAIL PROTECTED]
> 
> 

Reply via email to