Reputation: 1
I am trying to use getline() function. I am using correct syntax I guess and also I have included #include<stdio.h> header file also. Still it is showing that [Error] 'getline' was not declared in this scope
here is my code
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char *str;
int bytes_read;
int size=10;
printf("please enter a string");
str=(char *)malloc(size);
bytes_read=getline(&str,&size,stdin);
puts(str);
}
Upvotes: 0
Views: 1076
Reputation: 31
getline is a POSIX function, and Windows isn't POSIX, so it doesn't have some POSIX C functions available.
You'll need to define the feature macro _GNU_SOURCE in order to make it available for your code.
#define _GNU_SOURCE
Upvotes: 0