确实整数或c的任何其他数据类型的大小依赖于底层结构? [英] Does the size of the integer or any other data types in C dependent on the underlying architecture?

查看:132
本文介绍了确实整数或c的任何其他数据类型的大小依赖于底层结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>

int main()
{
  int c; 
  return 0;
} // on Intel architecture

#include <stdio.h>

int main()
{
  int c; 
  return 0;
}// on AMD architecture

/ *
 在这里,我有两个不同的机器上code和我想知道'是数据类型依赖于机器的大小
* /

/* Here I have a code on the two different machines and I want to know the 'Is the size of the data types dependent on the machine ' */

推荐答案

在这里看到:
<一href=\"http://stackoverflow.com/questions/4091826/size-guarantee-for-integral-arithmetic-types-in-c-and-c\">size对于积分/运算类型C和C ++保证

基本的C类型大小取决于实现(编译器)和架构,但是他们有一些保障的界限。每个人都应该因此永远难以code类型的大小,而使用的sizeof(类型名称),以获得字节它们的长度。

Fundamental C type sizes are depending on implementation (compiler) and architecture, however they have some guaranteed boundaries. One should therefore never hardcode type sizes and instead use sizeof(TYPENAME) to get their length in bytes.

这篇关于确实整数或c的任何其他数据类型的大小依赖于底层结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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