将相同值分配给多个变量的最少键入量是多少 [英] what is the least amount of typing to assign the same value to multiple variables
问题描述
这种语法不起作用
nl,nt,ns = 0;
唯一得到初始化的是ns。
nl和nt因为他们没有初始化似乎从
内存得到一些垃圾。
我做了这两个版本的工作:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
我想知道它的正常工作方式是什么?在下面的上下文我
想知道逗号是如何被解释为:
nl,nt,ns = 0;
谢谢任何见解。
vlsidesign写道:
此语法不工作
nl,nt,ns = 0;
唯一获得初始化的是ns。
nl和因为他们没有初始化似乎从
内存中获得了一些垃圾。
我已经完成了这两个版本的工作:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
我想知道它的正常工作方式是什么?在下面的上下文我
想知道逗号是如何被解释为:
nl,nt,ns = 0;
谢谢任何见解。
只是好奇:为什么这很重要?如果你需要数百万个变量,
只需要make和array,并用循环初始化它。或者使用calloc(),
,它的工作方式类似于malloc(),但是将缩写初始化为0.
merry Xmas,Furious_joe
furious_joe写道:
只是好奇:为什么这很重要?如果你需要数百万个变量,
只需要make和array,并用循环初始化它。或者使用calloc(),
,其作用类似于malloc(),但是将缩写初始化为0.
merry Xmas,Furious_joe
$ b第3行
$ b,make之间和阵列是一个校对的理由,而不是
相信一个拼写检查器。
它不是,我是一个新手,只是想知道。我正在阅读
C编程语言。由Kernighan和Ritchie,第二版
版本 - 这本书看起来非常好。
furious_joe写道:
vlsidesign写道:
此语法不起作用
nl,nt,ns = 0;
唯一被初始化的是ns。
nl和nt因为他们没有初始化似乎从
内存得到一些垃圾。
我做了这两个版本的工作:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
我想知道它的正常工作方式是什么?在下面的上下文我
想知道逗号是如何被解释为:
nl,nt,ns = 0;
谢谢任何见解。
只是好奇:为什么这很重要?如果你需要数百万个变量,
只需要make和array,并用循环初始化它。或者使用calloc(),
,它的作用类似于malloc(),但是将缩写初始化为0.
merry Xmas,Furious_joe
This syntax does not to work
nl, nt, ns = 0;
The only one that get''s initialized is ns.
nl and nt because they don''t initialize seem to get some junk from
memory.
I have done these two versions that work:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
I wonder what is the normal way it is done? In the context below I
wonder how the commas are interpreted as:
nl, nt, ns = 0;
Thanks for any insight.
vlsidesign wrote:This syntax does not to work
nl, nt, ns = 0;
The only one that get''s initialized is ns.
nl and nt because they don''t initialize seem to get some junk from
memory.
I have done these two versions that work:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
I wonder what is the normal way it is done? In the context below I
wonder how the commas are interpreted as:
nl, nt, ns = 0;
Thanks for any insight.
Just curious: why does it matter? If you need millions of variables,
just make and array, and initialize it with a loop. or use calloc(),
which works like malloc(), but initializes the condense to 0.
merry Xmas, Furious_joe
furious_joe wrote:Just curious: why does it matter? If you need millions of variables,
just make and array, and initialize it with a loop. or use calloc(),
which works like malloc(), but initializes the condense to 0.
merry Xmas, Furious_joeon line 3, between "make" and "array" is a reason to proofread, and not
trust a spell checker.
It doesn''t, I am a newbie and just wondering. I am going through the
"The C programming language" by Kernighan and Ritchie, the Second
edition -- this book seems very good.
furious_joe wrote:vlsidesign wrote:This syntax does not to work
nl, nt, ns = 0;
The only one that get''s initialized is ns.
nl and nt because they don''t initialize seem to get some junk from
memory.
I have done these two versions that work:
nl = 0; nt = 0; ns = 0;
nl = nt = ns = 0;
I wonder what is the normal way it is done? In the context below I
wonder how the commas are interpreted as:
nl, nt, ns = 0;
Thanks for any insight.Just curious: why does it matter? If you need millions of variables,
just make and array, and initialize it with a loop. or use calloc(),
which works like malloc(), but initializes the condense to 0.
merry Xmas, Furious_joe
这篇关于将相同值分配给多个变量的最少键入量是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!