C变量长度 [英] C Variables Length

查看:102
本文介绍了C变量长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友。

我想知道c中可变长度是多少。

我K& R他们说至少31个字符。

但是我给变量一个十万分之一的长度,但我的编译器没有说

任何错误。

接受它。那么最大长度是多少变量。?

解决方案

12月14日下午2:53,lak< l ... @ nospam.invalidwrote :


你好朋友。

我想知道c中的变量长度是多少。

I K& ; R他们说至少31个字符。

但我给变量一个十万分之一的长度,但我的编译器并没有说

任何错误。

它接受它。那么变量的最大长度是多少。?



更合适的参考是C语言标准。它说:


5.2.4.1翻译限制

1实施应能翻译并执行至少

一个程序其中包含以下限制中每一个

的至少一个实例:13)

* 127嵌套级别的块

* 63嵌套级别条件包含

* 12指针,数组和函数声明符(以任意组合)

修改算术,结构,联合或不完整类型

声明

* 63完整的

声明符中的括号声明符号的嵌套级别

* 63完整的括号内表达式的嵌套级别

表达式

* 63内部标识符中的重要初始字符或

宏名称(每个通用字符名称或扩展源字符
被视为单个字符)

* 31个外部标识符中的重要初始字符(每个
通用字符名称指定短标识符0000FFFF或

less被认为是6个字符,每个通用字符名称

指定短标识符00010000或更多被认为是10

个字符,并且每个扩展源字符被认为是相同的

字符数作为相应的通用字符名称,如果

任何)14)

* 4095外部标识符在一个翻译单元

* 511标识符,块范围在一个块中声明

* 4095宏标识符同时在一个预处理中定义

翻译单元

* 127个参数在一个函数定义中

* 127个参数在一个函数调用中
$一个宏定义中的b $ b * 127个参数
一个宏调用中的
* 127个参数

*逻辑源行中的4095个字符

*字符串文字或宽字符串文字中的4095个字符

(连接后)

*对象中的65535字节(仅限托管环境)

* 15个#included文件的嵌套级别

* 1023开关语句的案例标签(不包括任何

嵌套开关语句的案例标签)

* 1023个单一结构或工会成员

* 1023枚举常量在单个枚举中

* 63级嵌套结构或联合定义在单个

struct-declaration-list中


因此,您可以在内部

标识符中包含最多63 *个* *字符。这意味着你可以制作一个100个字符,但

只会识别前63个字符,以区别于其他

标识符。

C99之前的实现可以将内部标识符中的31 *初始*字符限制为

。这意味着你可以制作一个100个字符

长,但只有前31个字符可以识别出来与其他标识符区别开来。


lak< la*@nospam.invalidwrites:


我想知道c中的变量长度是多少。

我K& R他们说至少31个字符。

但我给变量一个十万分之一的长度,但我的编译器没有说任何错误




标识符中的重要字符数在实现中变化为
。对于C90内部

标识符至少为31,外部标识符为6,并且比每种情况下C99更高




我不知道什么是十字架是。

-

char a [] =" \ n .CJacehknorstu" ;; int putchar(int); int main(void){unsigned long b [ ]

= {0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},* p

= b,i = 24; for(; p + =! * p; * p / = 4)开关(0 [p]& 3)情况0:{return 0; for(p - ; i - ; i - )case +

2 :{i ++; if(i)break; else default:continue; if(0)case 1:putchar(a [i& 15]); break;}}}


< blockquote> Ben Pfaff写道:


lak< la*@nospam.invalidwrites:


>我想知道c中的变量长度是多少。
我K& R他们说至少31个字符。
但我给变量一个十万分之一长度,但我的编译器并没有说<任何错误。



标识符中的重要字符数在实现中变化为
。对于C90内部

标识符至少为31,外部标识符为6,并且比每种情况下C99更高




我不知道什么是十字架是。



1E5,或GIYF。


-

Eric Sosman
< a href =mailto:es ***** @ ieee-dot-org.inva> es ***** @ ieee-dot-org.inva lid


Hello firends.
I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.
It accepts it.Then what is the maximum length to a variable.?

解决方案

On Dec 14, 2:53 pm, lak <l...@nospam.invalidwrote:

Hello firends.
I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.
It accepts it.Then what is the maximum length to a variable.?

A more appropriate reference is the C language standard. It says:

5.2.4.1 Translation limits
1 The implementation shall be able to translate and execute at least
one program that contains at least one instance of every one of the
following limits:13)
* 127 nesting levels of blocks
* 63 nesting levels of conditional inclusion
* 12 pointer, array, and function declarators (in any combinations)
modifying an arithmetic, structure, union, or incomplete type in a
declaration
* 63 nesting levels of parenthesized declarators within a full
declarator
* 63 nesting levels of parenthesized expressions within a full
expression
* 63 significant initial characters in an internal identifier or a
macro name (each universal character name or extended source character
is considered a single character)
* 31 significant initial characters in an external identifier (each
universal character name specifying a short identifier of 0000FFFF or
less is considered 6 characters, each universal character name
specifying a short identifier of 00010000 or more is considered 10
characters, and each extended source character is considered the same
number of characters as the corresponding universal character name, if
any)14)
* 4095 external identifiers in one translation unit
* 511 identifiers with block scope declared in one block
* 4095 macro identifiers simultaneously defined in one preprocessing
translation unit
* 127 parameters in one function definition
* 127 arguments in one function call
* 127 parameters in one macro definition
* 127 arguments in one macro invocation
* 4095 characters in a logical source line
* 4095 characters in a character string literal or wide string literal
(after concatenation)
* 65535 bytes in an object (in a hosted environment only)
* 15 nesting levels for #included files
* 1023 case labels for a switch statement (excluding those for any
nested switch statements)
* 1023 members in a single structure or union
* 1023 enumeration constants in a single enumeration
* 63 levels of nested structure or union definitions in a single
struct-declaration-list

So you can have up to 63 *initial* characters in an internal
identifier. That means you might make one 100 characters long, but
only the first 63 would be recognized to differentiate it from other
identifiers.
Some pre-C99 implementations may limit to 31 *initial* characters in
an internal identifier. That means you might make one 100 characters
long, but only the first 31 would be recognized to differentiate it
from other identifiers.


lak <la*@nospam.invalidwrites:

I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.

The number of significant characters in an identifier varies
among implementations. It is at least 31 for internal
identifiers and 6 for external identifiers in C90, and higher
than that in each case for C99.

I don''t know what a "lakh" is.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}


Ben Pfaff wrote:

lak <la*@nospam.invalidwrites:

>I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.


The number of significant characters in an identifier varies
among implementations. It is at least 31 for internal
identifiers and 6 for external identifiers in C90, and higher
than that in each case for C99.

I don''t know what a "lakh" is.

1E5, or GIYF.

--
Eric Sosman
es*****@ieee-dot-org.invalid


这篇关于C变量长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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