This is the 24th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”


Recently, I want to review C language, so I will update an article about C language in nuggets every day! Freshmen who are just learning C, and those who want to review C /C++, don’t miss it! Solid foundation, slow down is fast!



1. Debug shortcut keys

Tip: CTRL +H: Replace CTRL +F: Find CTRL + up and down arrow keys: Scroll the code screen without moving the cursor position. Ctrl+Shift+/ block comment code (press cancel twice) Ctrl+K+C Comment code Ctrl+K+U Uncomment code Ctrl+G Jump to specified line F5: Start debugging Ctrl+F5: Start execution (no debugging) Shift+F5: Stop debugging Ctrl+Shift+F5: Restart debugging F9: Toggle breakpoints Ctrl+F9: Enable/stop breakpoints Ctrl+Shift+F9: Delete all breakpoints F10: Process by process Ctrl+F10: Run to cursor F11: statement by statementCopy the code

2. Basic debugging steps


3.Debug and Release versions

Debug version: Debug version – Can be debugged

Release version: Release version – For user use, cannot be debugged


Q: What version did the tester test?

-> The tester tests the release version from the user’s point of view


4.F9 sets breakpoint and F5 jumps to breakpoint. Press F9 to set breakpoint and then F5 to jump to breakpoint

If there are multiple breakpoints, press F5 to skip to the next breakpoint to skip code that does not need to be debugged


5. Set a conditional breakpoint

First you need to set the breakpoint (F9), right-click the breakpoint

A breakpoint is triggered when a condition is met


Multiple breakpoints: Execute the contents of the first breakpoint before executing the next breakpoint

To jump from one location to another —- type a breakpoint -> after jumping to that location, remove the breakpoint and type another one


6. A bad code

int main(a)
{
	int i = 0;
	int arr[10] = { 1.2.3.4.5.6.7.8.9.10 };
	for (i = 0; i <=12; i++)
	{
		arr[i] = 0;
		printf("hehe\n");
	}
	return 0;
}
Copy the code

Result: HeHE is printed in an infinite loop


To find problems: Print how many times to print

int main(a)
{
	int i = 0;
	int arr[10] = { 1.2.3.4.5.6.7.8.9.10 };
	for (i = 0; i <=12; i++)
	{
		arr[i] = 0;
		printf("hehe\n");
		printf("Print %d \n",i);
	}
	return 0;
}
Copy the code

I can’t go to 12


Debugging result:

When you change the subscript 12 of the first element to 0, I returns to 0, so an infinite loop is created

Why is that?

Here is a small question, the next article for you to answer, you can consider it oh!

That’s all for today. Thank you for seeing us! Hope to help you! You are welcome to click on this topic and subscribe! At the same time, welcome the bigwigs to criticize and correct!