c - 使用 fpurge(stdin) 时出错;

标签 c string ubuntu-14.04

这是我尝试在 ubuntu 14.04 上使用 gcc 编译器编译的程序的一部分。

#include<stdio.h>
#include<string.h>

main() {
    int i;
    char str[50], pat[3];
    char sep;
    printf("Enter the sting to seperate\n ");
    scanf("%s", str);
    fpurge(stdin);
    printf("Enter the patern in Numbers to seperate Example : 1 2 3\n");
    //__fpurge(stdin);
    scanf("%s", pat);
    fpurge(stdin);
    printf("Enter the seperator Example: ; or enter ,space");
    scanf("%c", &sep);
}

这是错误:

 /tmp/cc0bHLkO.o: In function `main':
 str_sepert.c:(.text+0x4d): undefined reference to `fpurge'
 str_sepert.c:(.text+0x95): undefined reference to `fpurge'
 collect2: error: ld returned 1 exit status

最佳答案

fpurge 不在标准 C 库中。它是非标准的,不 便携的。这是一个 BSD 函数。

http://bytes.com/topic/c/answers/845246-fpurge

关于c - 使用 fpurge(stdin) 时出错;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33066454/

相关文章:

string - 使用 `pop3::POP3Stream::connect` 连接到给定 `host` 的运行时?

比较从文件中读取的字符串

java - 将单个二进制字符串值拆分为数组

qt - 为 Qt 5 安装 postgres 驱动程序

c - 在 C 中不使用 fseek 移动文件位置

c - 如何释放只包含指针的结构

c - OpenGL/OpenCL 互操作、OpenCL 渲染到纹理的麻烦

c - C 编程中内存(位)如何工作

c++ - G++ 编译,可执行文件无法运行

c++ - Ubuntu 14.04 上的 Eclipse C++ 找不到字符串的 stod()