Debugging Code in Dev-C++: Solving an Unexpected Disappearance

  • Context: C/C++ 
  • Thread starter Thread starter FrostScYthe
  • Start date Start date
  • Tags Tags
    Code Debugging
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
FrostScYthe
Messages
80
Reaction score
0
Ok, I'm trying this code in Dev-C++

int main(int argc, char **argv)
{
double **a;
double *b;
// double *m;
int n, iter;
double tol;

b = new double[n];

a = new double*[n];
for (int i = 0; i < n + 1; i++)
a = new double[n];

// m = new double[n];

count << "I'm ready to continue =)!";

system("PAUSE");
return 0;
}

If I omit the m vector, the program will run and not disappear in a second and it will be ready to continue.. but when I declare the m vector without even doing anything with it... it just runs and quits quicker than I can blink my eye...! Why is this happening =(?
 
Physics news on Phys.org
Forget this post, I just realized I had to initialize n before doing any of this ... tehe =)
 
n is undefined.

Edit: Sorry, just saw your follow up.