错误:格式未知的转换类型字符“ l”-长扫描长 [英] error: unknown conversion type character 'l' in format - scanning long long
问题描述
我正尝试使用标准IO功能 scanf
从控制台获取长
。我从%lld
开始:
I'm trying to get long long
from the console using standard IO function scanf
. I started with %lld
:
scanf("%lld", &rule);
该抛出:
error: unknown conversion type character 'l' in format [-Werror=format=]
的未知转换类型字符 l
我发现了更多解决方法,但它们也引发了错误:
I've found more workarounds, but they too throw errors:
scanf("%I64d", &rule);
->error: ISO C does not support the 'I64' ms_scanf length modifier [-Werror=format=]
scanf("%"SCNd64"", &rule);
->error: expected ')' before 'SCNd64'
我在做什么错误?还有另一把戏吗?
Am I doing something wrong? Is there an another trick?
我正在使用以下标志对MinGw GCC的最新版本进行编译: -pedantic -Wall -Werror -std = c99 -g -D HOME = 1
I'm compiling on very recent version of MinGw GCC with these flags: -pedantic -Wall -Werror -std=c99 -g -D HOME=1
推荐答案
用于 SCNd64
和类似的东西,您必须使用
for SCNd64
and similar, you'd have to use
#include <inttypes.h>
但这一切仅在编译器支持C99的情况下才有效。您的第一条错误消息强烈表明它没有,或者您没有提供正确的命令行开关。
but all of this is only supposed to work if your compiler supports C99. Your first error message is a strong indication that it doesn't, or that you didn't give the right commandline switches.
这篇关于错误:格式未知的转换类型字符“ l”-长扫描长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!