Home > Back-end >  Codeblocks can debug, but the runtime error?
Codeblocks can debug, but the runtime error?

Time:11-11

Written in c + + code, run time error, but the single-step tracking and can obtain correct results,
 
#include
# include
# include
using namespace std;

Int main ()
{
Double a1 [4]={1.1, 1.2, 1.3, 1.4};
Vector A2 (4);

A2 [0]=1.0/3;
A2 [1]=1.0/5;
A2 [3]=1.0/7;
A2 [4]=1.0/9;

ArrayArray
Cout & lt; <"A1 [2]=" & lt; Cout & lt; <"A2 [2]=" & lt; Cout & lt; <"A3 [2]=" & lt; Cout & lt; <"A4 [2]=" & lt;
return 0;
}


The results

Single-step tracking results

CodePudding user response:

I also encountered the same problem, and solve

CodePudding user response:

No environment, a bit, the original poster check yourself for not

1, the definition of a2 vector A2 (4); To vector A2 [4]. Try

2, a2 subscript, 0,1,3,4 is overrun

CodePudding user response:

Vector A2 (4);
A2 is initialized to, 4 the default value of 0
element
A2 [4], crossing the line,,,,
  • Related