简体   繁体   English

如何从数组中复制值并将其分配给c中的另一个数组?

[英]How to copy value from an array and assign it to another array in c?

In python i will do like 在Python中,我会喜欢

grid = [['a','b','c'],['d','e','f'],['g','h','i']]
another_grid = [['a','a','a'],['d','e','f'],['g','h','i']]
another_grid[0][1] = grid[1][1]

Above code will change 'a' to 'e' . 上面的代码会将'a'更改为'e' How to do this in c ? 如何在c中执行此操作?

It's the same, even the syntax is similar: 相同,甚至语法相似:

char grid[3][3] = { { 'a', 'b', 'c' }, { 'd', 'e', 'f' }, { 'g', 'h', 'i' } };
char another[3][3] = { { 'a', 'a', 'a' }, { 'd', 'e', 'f' }, { 'g', 'h', 'i' } };
another[0][1] = grid[1][1];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数组的值分配给 c 中的另一个数组(复制)? - How to assign values of array to another array(making copy) in c? 如何将值从第一个数组复制到另一个数组? - How to copy a value from first array to another array? 如何将数组值复制到另一个数组 - How to copy array value to another array 如何在数组中查找一个值并将其复制到 C 语言中的另一个值? - How to find a value in array and copy it to another one in C language? 如何在C中将char数组分配给另一个具有另一个大小的char数组 - how to assign char array to another char array with another size in C 如何使用指针算法在C中将值从一个数组复制到另一个数组 - How to copy values from one array to another in C with pointer arithmetic 如何将单个字符从字符串数组复制到“ C”中的另一个字符串 - How to copy single chars from an array of strings to another string in “C” 如何在C中将一个char数组的整个值分配给十六进制格式的一个位置的另一个数组? - How to assign the whole value of one char array into another array of one position into hex format in C? 如何将数组的一部分从2d数组复制到C中的另一个数组中 - How to copy part of an array from a 2d array into another array in C 如何为 C 中的结构数组赋值? - How to assign a value to an array of structures in C?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM