On 03-Aug-98 Torbjørn S. Kristoffersen wrote:
> How can I make a C program that reads line by line from a file?
> I want to pass each line into a string.
> 
> Here's my code so far:
> 
> ---------------------------
>#include <stdio.h>
> 
> int main()
> {
>     FILE *fil;
>     char line[50];
>     int c;
> 
>     if((fil=fopen("file.1","r")) == NULL)
>     {
>        printf("Couldn't open \"file.1\".\n");
>        exit(1);
>     }
> 
>     fgets(line, sizeof(line), fil);
>     printf("%s",line);
> }
> ---------------------------

Try sprintf instead of printf (see man sprintf for details) 

MfG

Jens 
---
--------------------------------------------------------
Jens Link                       [EMAIL PROTECTED]
FAX: 089-66617-31040            and soon: http://....
--------------------------------------------------------

Reply via email to