Question: What is wrong with the following program? int main ( ) { int some _ ints [ 5 ] = { 1 , 2 ,

What is wrong with the following program?
int main(){
int some_ints[5]={1,2,3,4,0};
for (int *p = some_ints; p; ++p)
*p =0;
return 0;
}// main()
main () indexes out of bounds into some_ints
main () leaks the memory pointed to by some_ints
some_ints points to uninitialized memory
the for loop is missing a curly brace, so this code will not compile
nothing is wrong with this program
What is wrong with the following program? int

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!