【发布时间】:2012-10-18 05:53:26
【问题描述】:
我正在学习在 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 64bit + Eclipse Indigo + MinGW
【问题讨论】:
-
你试过用
-std=gnu90编译吗?
标签: c reference undefined getline mingw32