How I can assign elements of tow dimensional array to one dimensional array? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How I can assign elements of tow dimensional array to one dimensional array?

If I have a two dimensional array with size 3*3 and I need to assign elements to one dimensional array with size 9 How I can do that?

13th May 2022, 7:15 PM
ABUBAKAR ALHOMIDY
ABUBAKAR ALHOMIDY - avatar
3 Respostas
0
By looping over every element in those array and adding them to that new array. You can use brute force with a double nested loop.
13th May 2022, 7:23 PM
Justice
Justice - avatar
0
You know how to access 2d elements! You know how to assign 1d elements! Find out your own way.. a_1d[index1] = a_2d[row][column]; Hope these helps... You can use memcpy() function also to just coping.... https://stackoverflow.com/questions/19913596/c-2d-array-to-1d-array http://www.cplusplus.com/forum/general/263317/
13th May 2022, 7:30 PM
Jayakrishna šŸ‡®šŸ‡³
0
isnt 3*3 3 dimensional "i am still learning"
14th May 2022, 5:19 PM
learner
learner - avatar