gggggggggggg
Printable View
gggggggggggg
Most bugs dont cause the compiler to spit out an error. Most occur during runtime. For this you need to attach the debugger and step through your code watching the variables closely as i have already told you. You need to know what to expect, so as to see when something went wrong. When you find variables that hold values that are unexpected, if you are singlestepping your code you will see exactly where it happens and so be able to start working on solving the errors.
In future as you write each function, test it to ensure what you think is happening is actually what is happening.
Why cant you debug your code? What compiler and debugger and IDE are you using? Look in the docs for it to see how to work the debugger. Its time for you to learn.
kkkkkkk
Nope. Not wierd at all. Learn to use your debugger. Use your debugger.
Watch this.
nnn
Everyone who has responded to you can solve the issue. The problem is can you solve it? That requires you to just sit down and learn how to debug your program using the debugger that comes with your compiler.
You didn't do that -- the only thing you did was write a big program, tried to run it, and want us to fix it without any effort on your part to see what is wrong.
Even if you didn't have a debugger, where are the cout statements to help you to know what the values of variables are, what lines of code you're executing, etc.? This is the harder way to debug, but at least it's something, but you didn't even do that.
Regards,
Paul McKenzie
This program compiles OK. What do you think happens when y is computed (i.e. a divide by zero happens)? Will the program get to the cout statement?Code:#include <iostream>
int main()
{
double x = 1.0;
double y = x / (x - 1.0);
std::cout << y;
}
This program compiles fine. What do you think happens when you assign a value to a NULL address?Code:#include <iostream>
int main()
{
char *p = 0;
*p = 'x';
std::cout << p;
}
Just because a program compiles doesn't mean when you run it, everything is OK. Is that what you were expecting, that all programs "work", and there is no need to debug them?
Regards,
Paul McKenzie
rrrrr
tttttt
One, we wouldn't be able to just look at the code and tell what is wrong. We would need to debug it. An IDE will have an option to debug your program. You can set a breakpoint at a line. From there, you will have options to step through the code. When you get to a function, you can either step over that function or step into that function. Really, if you are going to program in C++, using the debugger is a must.
aaaaaaa
Those are not warnings from the debugger. Those are warnings from the compiler when you are building your program.
The debugger is used when your program has been built, and you are running your program, and you are seeing how your program runs by inspecting the value of variables, setting breakpoints, etc.
Regards,
Paul McKenzie
I thought it was to keep the teacher and classmates out of it.