scanf 的四边形和参数类型 [英] quadmath and argument type for scanf

查看:59
本文介绍了scanf 的四边形和参数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 .使用哪种参数类型可以正确读取我的输入?如果我使用 double 它看起来像:

I use the <quadmath.h>. With which argument type can I read my input correctly? If I use double it looks like:

printf("enter 3 values for s, t and mt:\n");
scanf("%lf %lf %lf", &s, &t, &mt);
printf("%lf %lf %lf\n", s, t, mt);

我尝试了不同的可能性而不是l",例如:

I tried different possibilities instead of "l" for example:

scanf("%Qf %Qf %Qf", &s, &t, &mt);

甚至没有

 scanf("%f %f %f", &s, &t, &mt);

但是我得到一个错误.

推荐答案

scanf(以及相关函数和 printf 和相关函数)不可扩展em>.它只能解析标准库知道的内容.C 标准库随操作系统一起提供,而不是编译器.它不知道 libquadmath,它是一个编译器扩展.

scanf (and related functions and printf and related functions) is not extensible. It can only parse what the standard library knows about. The C standard library comes with the operating system, not the compiler. It does not know about libquadmath, which is a compiler extension.

因此您必须读取字符串并使用 strtoflt128 分别转换它们.

So you'll have to read strings and convert them separately using strtoflt128.

请注意,可以扩展 C++ 流以提取 __float128,但我在 quadmath 库中没有看到 C++ 接口.

Note that C++ streams can be extended to extract __float128, but I don't see C++ interface in the quadmath library.

这篇关于scanf 的四边形和参数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆