我正在学习在C编程中使用getline函数,并尝试了来自http://crasseux.com/books/ctutorial/getline.html的代码。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int atgc, char *argv[])
{
int bytes_read = 1;
int nbytes = 10;
char *my_string;
my_string = (char *)malloc(nbytes+1);
puts("Please enter a line of text");
bytes_read = getline(&my_string, &nbytes, stdin);
if (bytes_read == -1)
{
puts ("ERROR!");
}
else
{
puts ("You typed:");
puts (my_string);
}
return 0;
}
然而,问题在于编译器不断返回这样的错误:undefined reference to 'getline'。请问您能告诉我问题出在哪里吗?谢谢!
我正在使用Win7 64位 + Eclipse Indigo + MinGW。