Nakib
Nakib

Reputation: 4713

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

In python i will do like

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'. How to do this in c ?

Upvotes: 0

Views: 241

Answers (1)

user529758
user529758

Reputation:

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];

Upvotes: 1

Related Questions