Any Help on Debugging my code, Please? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 4

Any Help on Debugging my code, Please?

Hello there coders, I just started learning to code, so I was trying to build a simple program to practice. My little program was built to get some numbers, build an array with them, them show the table at the end. At this point, the major problem I'm facing is that I can't assingn more than 2 lines to the array before it starts to behave strangely. (I think it may be ralated to the size of my array) Hope you can help me out: there is my C++ code: https://code.sololearn.com/cboR60m3Ys7e/#cpp

6th Nov 2018, 3:29 AM
Caio Yon
Caio Yon - avatar
2 Respuestas
+ 3
Arrays do not grow automatically to fit any space requirement dynamically. You could either do dynamic memory management yourself (using 'new' and 'delete[]' or 'unique_ptr') and keep track of all necessary parameters. Or better, let C++ do that for you and use a vector container instead. It is designed for dynamic size. You could start here: http://www.cplusplus.com/reference/vector/vector/
6th Nov 2018, 6:01 AM
Leif
Leif - avatar
+ 1
Thank you so much Leif. Unfortunately it is more complex than I thought it would be. So, I will need to study some more to fix it. But I really appreciate your tip! I had no idea how to do it. Once It's done I will post the complete code here.
6th Nov 2018, 10:48 AM
Caio Yon
Caio Yon - avatar