Answers for "how to add elements in an array in for loop c++"

C++
0

how to add elements in an array in for loop c++

int * myVar = new int [5];
for (int i = 0; i < 5; i++)
	myVar[i] = i

// 0 1 2 3 4 myVar in the array 

// delete stuff *optional*
delete [] myVar;
myVar = NULL; 

// free up memory declared on the stack
Posted by: Guest on November-16-2020

Code answers related to "how to add elements in an array in for loop c++"

Browse Popular Code Answers by Language