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

I'm confused about the n variable.In summary, the conversation discusses an attempt to run a code in Dev-C++, where the code involves the use of a double vector. However, when the m vector is declared without being used, the program runs and quits quickly. The issue is resolved when the n variable is initialized beforehand.
  • #1
FrostScYthe
80
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];

cout << "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 =(?
 
Technology news on Phys.org
  • #2
Forget this post, I just realized I had to initialize n before doing any of this ... tehe =)
 
  • #3
n is undefined.

Edit: Sorry, just saw your follow up.
 

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

1. Why did my code disappear when I tried to debug it in Dev-C++?

There could be several reasons for this. It could be a bug in the Dev-C++ software, a mistake in your code, or an error in your debugging process. It is important to carefully review your code and debugging steps to try and identify the cause of the disappearance.

2. How can I prevent my code from disappearing while debugging in Dev-C++?

To prevent your code from disappearing, make sure to regularly save your code as you work on it. Also, try to avoid making changes to your code while debugging, as this can sometimes cause unexpected issues. It is also a good practice to save your code in a separate file before debugging, so that you have a backup in case anything goes wrong.

3. What should I do if my code disappears while debugging in Dev-C++?

If your code disappears while debugging, the first step is to remain calm and try to identify what might have caused the issue. Check for any recent changes you made to your code or any errors that might have occurred during the debugging process. If you are unable to find the cause, you may need to restart the debugging process or consult with a more experienced programmer.

4. Is there a way to recover my code if it disappears while debugging in Dev-C++?

In some cases, it may be possible to recover your code if it disappears while debugging. You can try to use the "Undo" function to revert any recent changes you made to your code or check for any temporary files that may have been created during the debugging process. If these options do not work, you may need to refer to a previous version of your code or rewrite the lost portions.

5. How can I avoid code disappearing in the future while debugging in Dev-C++?

To avoid code disappearing while debugging in Dev-C++, it is important to regularly save your code and avoid making changes to it during the debugging process. Additionally, it is always a good idea to backup your code in a separate file or use version control software to track changes and revert back to previous versions if needed.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
Replies
1
Views
961
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
32
Views
2K
  • Programming and Computer Science
Replies
6
Views
946
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
661
Back
Top