如何在创建多维数组后一次将多个值分配给它 - 在 C 中? [英] How to assign multiple values at once to multi-dimensional array AFTER creating it - in C?

查看:16
本文介绍了如何在创建多维数组后一次将多个值分配给它 - 在 C 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 C 编程,想知道是否可以一次将多个值分配给多维数组?我尝试了一些技术,但都失败了!我对遍历数组来分配值不感兴趣(我希望以快速的方式为数组中的所有索引分配新值).我正在使用的数组:ary[4][4].

I'm programming in C and wonder if it's possible to assign multiple values at once to a multi-dimensional array? I have tried some technique but all have failed! I’m NOT interested to loop through the array to assign values (I want the fasted way to assign new values to all index in the array). The array I’m working with: ary[4][4].

推荐答案

由于数组不是可修改的左值,因此它不能出现在赋值的左侧.您可以对其进行初始化,也可以通过索引分配单个成员.

Since an array is not a modifiable lvalue, it cannot appear on the left side of an assignment. You can initialize it and you can assign individual members via indexing.

6.3.2.1

一个可修改的左值是一个没有数组类型的左值,没有...

A modifiable lvalue is an lvalue that does not have array type, does not have ...

还有一个可修改的lvalue:

lvalue"这个名字最初来自赋值表达式 E1 = E2,其中要求左操作数 E1 是一个(可修改)左值.

The name ‘‘lvalue’’ comes originally from the assignment expression E1 = E2, in which the left operand E1 is required to be a (modifiable) lvalue.

所以不,你不能做你想做的事.

So no, you can't do what you want.

这篇关于如何在创建多维数组后一次将多个值分配给它 - 在 C 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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