0

Random error: this 'for' clause does not guard ...

They can run the code (from the retroman friend) and read the full error. When redoing it and after I finish implementing the function that frees the memory array, it compiles https://code.sololearn.com/c5GCWfnqYjP0/?ref=app It should only give the warning of unused variable. In the Prac Reserva_ matriz ( my code)code you can see it compile, already with the function of freeing matrix implemented. cout suele hacer eso por su buffer al intercalarlo entre reservas y liberaciones de memoria. Hay algo similar en el bucle for?

2nd Jan 2022, 7:21 AM
Master Forts đŸ‡ŠđŸ‡·
Master Forts đŸ‡ŠđŸ‡· - avatar
2 Answers
+ 1
You need curly braces. #include <iostream> #include <cstdint> using namespace std; #define SIZE 4 uint32_t** reserva_matriz (){ uint32_t **m = new uint32_t* [SIZE]; for(uint32_t i=0;i<SIZE;i++) { m[i] = new uint32_t [SIZE]; } return m; } int main() { uint32_t **m; m = reserva_matriz(); cout << m; return 0; }
2nd Jan 2022, 7:29 AM
FanYu
FanYu - avatar
0
yes, that's it. Thank you very much, I thought that being a short expression, the curly braces were not necessary
2nd Jan 2022, 7:38 AM
Master Forts đŸ‡ŠđŸ‡·
Master Forts đŸ‡ŠđŸ‡· - avatar