Why am i getting the followng error when I called getline() in my C code?

I am getting the following error

rudimentary_calc.c: In function ‘main’:
rudimentary_calc.c:9:6: error: conflicting types for ‘getline’
   9 |  int getline(char line[], int max) ;
     |      ^~~~~~~
In file included from rudimentary_calc.c:1:
/usr/include/stdio.h:616:18: note: previous declaration of ‘getline’ was here
 616 | extern __ssize_t getline (char **__restrict __lineptr,
     |                  ^~~~~~~

when I ran the following code

#include <stdio.h>

#define maxline 100

int main()
{
    double sum, atof(char[]);
    char line[maxline];
    int getline(char line[], int max) ;

    sum = 0;

    while (getline(line, maxline) > 0)
        printf("\t %g \n", sum += atof(line));
    return 0;

}

What am I doing wrong? I am very new to C, so I don't know what went wrong.



from Recent Questions - Stack Overflow https://ift.tt/3h94qCd
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation