How Do I store more than one item on the same Index If one array? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

How Do I store more than one item on the same Index If one array?

Ok, I have one array, but in my code to the same Index If that array, I have 50 values for to that same Index, but when I try to generate one file with all that information, the file have only the last information, and discart all 49. https://code.sololearn.com/c04UTMr60iHq/?ref=app

12th Jun 2019, 12:56 PM
Isaac Muniz
Isaac Muniz - avatar
3 Antworten
+ 7
Each index stores one number. If you 'add' another one, you are really overwriting the former value. If you want to store many values per index, you can use a twodimensional array. int numbers[10][50]; This creates an array with ten sub-arrays for 50 numbers. Then you can access each element of one of the arrays by double index. printf("%d", numbers[4][49]); This prints the 50th number of the 5th array.
12th Jun 2019, 1:08 PM
HonFu
HonFu - avatar
+ 1
Thanks man ❤️❤️❤️, this really help me.
12th Jun 2019, 1:12 PM
Isaac Muniz
Isaac Muniz - avatar
0
Man, How I do generate this in a file?
12th Jun 2019, 2:05 PM
Isaac Muniz
Isaac Muniz - avatar