相关疑难解决方法(0)

c中对'getline'的未定义引用

我正在学习在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;
 }
Run Code Online (Sandbox Code Playgroud)

但是,问题是编译器不断返回错误:未定义的引用'getline'.你能告诉我问题是什么吗?谢谢!

我使用的是Win7 64bit + Eclipse Indigo + MinGW

c reference undefined getline mingw32

15
推荐指数
3
解决办法
3万
查看次数

标签 统计

c ×1

getline ×1

mingw32 ×1

reference ×1

undefined ×1