0

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 ?

4
  • another_grid[0][1] = grid[1][1]; will work in C. It's the defining an array of arrays part that will be different. Commented Dec 16, 2012 at 17:24
  • the code i had written in python will change value for another_grid[0][1] which is 'a' to grid[1][1] which is 'e' Commented Dec 16, 2012 at 17:24
  • I want to write that code in c Commented Dec 16, 2012 at 17:25
  • 1
    @Nakib By the way, why didn't you google this? Commented Dec 16, 2012 at 17:27

1 Answer 1

1

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];
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help. I thought i will be different as like assigning array.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.