本文介绍了将相同值分配给多个变量的最少键入量是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种语法不起作用

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


$ b第3行
$ b,make之间和阵列是一个校对的理由,而不是

相信一个拼写检查器。




只是好奇:为什么这很重要?如果你需要数百万个变量,

只需要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.

解决方案

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


on line 3, between "make" and "array" is a reason to proofread, and not
trust a spell checker.


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


这篇关于将相同值分配给多个变量的最少键入量是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 02:18