c - scanf:浮点格式未链接

标签 c scanf

<分区>

我收到错误 scanf: 未链接浮点格式 在读取以下结构的“信息”值时。

struct node
{
    float info; struct node *next;
}*start;

在主函数中

void main()
{
       struct node *temp;
       temp = (struct node*)malloc(sizeof(struct node));
       printf("enter data = ");
       scanf("%f",&temp->info);
}

它没有读取该 scanf 的任何值并从程序中出来。

如何解决这个问题?

最佳答案

此问题最有可能在使用 Turbo C/Borland C 编译器时出现。除非我们需要,否则这些编译器不会链接到浮点 (f-p) 库中。因此,当我们在 scanf()printf() 调用。

要修复此错误,请调用浮点 (f-p) 函数或仅添加文件链接,该文件至少包含一个浮点 (f-p) 函数。 例如。

void dummy(float *a) {
    float b=*a; //perform some floating access
    dummy (&b); //calling a floating point function
}

关于c - scanf:浮点格式未链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12366565/

相关文章:

c - OpenMP 通用 qsort 加速效果不佳

c - 通过套接字发送 C 字符数组

c - 如何读到/proc 文件的末尾

c++ - Borland C++ Builder 中的 scanf

c - C中的Scanf数组限制?

c - scanf() 在操作系统中如何工作?

c - 编码维吉尼亚密码时c中的段错误

c - C 如何将无符号转换为有符号的工作?

c - 在字符串上使用sscanf时,如何正确使用(否定的)字符类或扫描集?

c - 多个scanf?