printf的得到long long int用C与海湾合作委员会? [英] Printf long long int in C with GCC?

查看:113
本文介绍了printf的得到long long int用C与海湾合作委员会?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么printf的得到long long int 和使用GCC还无符号长long int类型在C99?

我已经搜索其他职位而建议使用%LLD ,但它给了这些警告:


  

警告#1:格式未知的转换式的人物'L'[-Wformat] |结果
  警告#2:参数太多的格式[-Wformat-额外参数] |


有关以下尝试:

 的#include<&stdio.h中GT;诠释的main()
{
   得到long long int x = 0;
   无符号长long int类型Y = 0;
   的printf(%LLD \\ n,x)的;
   的printf(%LLU \\ n,Y);
}


解决方案

如果您在Windows上使用MinGW的,海湾合作委员会使用Win32运行时,其中的printf需要%I64d号的64位整数。 (和%I64u为unsinged 64位整数)

对于大多数其他平台,您会使用%LLD打印很长很长。 (和%LLU如果是无符号)​​。这是在标化C99。

GCC不来一个完整的C运行时,它委托给它的运行平台上的 - 所以一般情况下,你需要查阅的文件为您的特定平台 - 独立的gcc

How do I printf long long int and also unsigned long long int in C99 using GCC?

I have searched the other posts which suggest to use %lld but it gives these warnings:

warning#1: unknown conversion type character 'l' in format [-Wformat]|
warning#2: too many arguments for format [-Wformat-extra-args]|

For the following attempt:

#include <stdio.h>

int main()
{
   long long int x = 0;
   unsigned long long int y = 0;
   printf("%lld\n", x);
   printf("%llu\n", y);
}

解决方案

If you are on windows and using mingw, gcc uses the win32 runtime, where printf needs "%I64d" for a 64 bit integer. (and "%I64u" for an unsinged 64 bit integer)

For most other platforms you'd use "%lld" for printing a long long. (and "%llu" if it's unsigned). This is standarized in C99.

gcc doesn't come with a full C runtime, it defers to the platform it's running on - so the general case is that you need to consult the documentation for your particular platform - independent of gcc.

这篇关于printf的得到long long int用C与海湾合作委员会?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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