Visual Stdio use (C language)

First, the new

1. vs set items:

Here Insert Picture Description
Solution (.sln file): it is the total project name, which is open when to open the file in the project folder
items (.vcxproj file): After being understood as part of the functionality of the package, such as: UIL, DAL, BLL three-tier architecture, each layer with a project to install. This is also divided into portions of executable files and dynamic link library What's different functions.

2. New Project (in C language as an example here)

Observe the process of the source folder anything generated at each step
(1) File -> New -> Project
(2) Select language: Here choose Visual C ++ -> windows console application (solution name below the total project name is the name .sln file name is the name of the project (as described above .vcxproj file))
1-2.1
click Next, and further provided
1-2.2
select empty project after the abolition security development lifecycle (SML) to check
1-2.3
into the interior items
1-2.4
(3) source code in the project: Right-click in (such as test1) "source file" -> Add -> New item (under the name set name and code categories .cpp or .c, where I set test1_1.c) (Figure 1)
head file: you can also right-click "header" -> Add -> header file
more than one item: Right-click solution -> Add -> New project after such 2. (2) (2)
here this function vs distribution prototype has emerged.
}1-2.6
1-2.7

Second, compiled using

1. Compile (generation)

(1) for generating a single item (here source code can not be run out of items)

Here Insert Picture Description
(2) were generated for the entire solution (a solution to a lot of projects under the program, all of generation)
Here Insert Picture Description

2. Debugging

(1) gradually run

Press F11 direct stepping debugging
Here Insert Picture Description

(2) to set a breakpoint

Most have left in view of a portion of the gray box, click inside the red breakpoint occurs, then F5 to run after he will stop at your breakpoint, then you may be continuing to step F11 to run.
Reference data breakpoints links: [in vs2015 data breakpoint]
数据断点能有效的检测对象数据的变化。当一个复杂程序(或者多线程中)有很多地方都可能改变某一个对象的值,如果一个对象被莫名更改而不知道是哪里对其做了修改,那么数据断点就派上用场了。数据断点创建后当程序修改此对象时程序就会中断运行,方便开发人员找到修改对象的代码位置。 设置数据断点 在含有此对象的代码处打上普通断点,程序运行到此后 Debug->New breakpoint->data breakpoint在地址处输入对象的地址或者&对象名 如果32位程序地址长度就是4字节,64位程序地址长度改为8字节。点击OK 然后继续run就好了。程序会在对象被改变的代码处自动break。
Here Insert Picture Description

3. Run

The best is to run after generation (compiler), you can run all together is compiled to run directly.
(1) Click on the "Local Windows Debugger" operation.
(2) F5
(3) "Debug" -> "Start Debugging" (best)

Fourth, some functions

1. Shortcuts

In the "Tools" -> "Options" -> "Keyboard" can be set to see shortcut keys
(1) selection Notes: Ctrl + K, Ctrl + C
(2) cancel the selection Notes: Ctrl + K, Ctrl + U

Fifth, the problems encountered

1.fflush (stdin) problem

Empty the buffer function fflush (stdin) is mainly used for the next input from the keyboard after the keyboard input again and needs to read the characters, because the last to enter a carriage return ', \ n' further remains in the buffer, so the next use it will scanf () or getchar () to read '\ n' is read, it is necessary to clean up the buffer zone.
But fflush (stdin) to normal use in VC6 environment, other compiler does not guarantee feasible, VS2017 will not take.
* Solution
using rewind (stdin) function to clear the buffer.

2. Custom headers can not be called

Problems encountered in the background is, Add Existing Item du.h in the source file, then the source file .c files directly want to introduce #include"du.h"
problem is that there is no prescribed path so the default is to introduce the current project folder in the file, but the software in the current folder and can not find du.h file.
* Solution:
Copy the file you want to introduce to the current folder.
Or to add the path name: this is too much trouble you, I'll just knock myself

#include"H:\C语言\C程序设计\第六章\C程序设计第六章\6.6(2)\du.h"
Published 18 original articles · won praise 1 · views 992

Guess you like

Origin blog.csdn.net/weixin_43773038/article/details/103457044