The easiest way to debug your code is to add print statements. To do this, you can add comments at various points in your code, such as:
cout << "line " << __LINE__ << ": x = " << x << endl;
The above line prints out the current line number as well as the value of the variable x when that line number executes, for example:
line 32: x = 3
Print statements work for debugging in (almost) any language and make repeated debug testing easy - to repeat debug testing with a new change, all you need to do is run the program again.
不懂为什么哎~~~~~~
cout << "line " << __LINE__ << ": x = " << x << endl;
The above line prints out the current line number as well as the value of the variable x when that line number executes, for example:
line 32: x = 3
Print statements work for debugging in (almost) any language and make repeated debug testing easy - to repeat debug testing with a new change, all you need to do is run the program again.
不懂为什么哎~~~~~~