Visual studio 2019 installation using C language program (vs2019 C language)

Time:2021-4-14

It has been a while since the new visual studio 2019 came out. Bloggers also changed from vs2017 to vs2019 at the beginning. They found that the overall operation process has changed to a certain extent, because they published a vs2017 blog before, and they really like the visual studio IDE and style. The font used by bloggers in vs2019 is Fira code. The next step is to write C program.

1 choose to create a new project

2 select an empty item and click next

3 fill in the name of the project (the generated folder name and project name are the same), I fill in Hello here, and choose the desktop as the saving location. At this time, after the project is set up, the desktop will generate a hello folder, check the solution and put the project in the same directory for debugging. After checking all, click create. Note that at this time the computer may be temporarily stuck, normal phenomenon, just wait a few seconds.

4 add C file

After creating in the previous step, you will get the following interface. Next, add the source file

In the solution directory on the left, select the source file, right-click, and select Add > new item, as shown in the figure below

Note that if the left side does not solve the resource manager, or accidentally shut down, as shown in the following figure

Click View > Project Explorer to call it out

The default page for adding a new item is as follows. Here are several points worth noting: 1. Select a C + + file (whether to write C or C + +); 2. The suffix of the name at the bottom is. CPP, which needs to be changed to. C when we write C code; 3. Just add a. C file here. If you want to add a. H file, we will introduce it later.

Select the C + + file, change the name to hello. C, and click Add

5 test in hello. C

Press Ctrl + F5 to compile and run directly, the result is as follows, and the printing is correct.

6 normal new projects have been OK here. In some projects, it may be necessary to transplant other people’s code. Usually, each. C file corresponds to a. H file. The adding process is as follows

The first step is to add the header file. H. The process is as follows: select the header file, right-click, add, and existing item

Here, I created max.h and max.c files in advance, which are used to calculate the maximum value of the two numbers. Add the following

Similarly, select the source file, right-click add existing item, and select max.c

7 in the main function, add the file and test it.

Test code:

#include <stdio.h>
void author_log(void);
int main(void)
{
	int max_value;	
 
	max_value = max(555, 666);
	printf("%d\n", max_value);
	author_log();
 
	getchar();
	return 0;
}
 
/*Print blog information*/
void author_log(void)
{
	printf("author name: dingyc \n");
	printf("author email: [email protected] \n");
}

Test results:

Max.c and max.h files for testing

max.c

/*Finding the maximum of two integers*/
 
int max(int num1, int num2)
{
	int max_value;
 
	if (num1 > num2)
	{
		max_value = num1;
	}
	else
	{
		max_value = num2;
	}
 
	return max_value;
}

max.h


#ifndef __MAX_H
#define __MAX_H 
int max(int num1, int num2); 
#endif /* __MAX_H */

Question:

Many students asked, visual studio prompt can not find # cinlude < studio. H > header file path, in fact, there is no installation of C + + tools. Check as shown below

“Using C + + desktop development”, can run normally.

This article about visual studio 2019 installation and use of C language program (vs2019 C language) is introduced here. For more related vs2019 installation and use of C language content, please search previous articles of developer or continue to browse the following related articles. I hope you can support developer more in the future!

Recommended Today

Review of SQL Sever basic command

catalogue preface Installation of virtual machine Commands and operations Basic command syntax Case sensitive SQL keyword and function name Column and Index Names alias Too long to see? Space Database connection Connection of SSMS Connection of command line Database operation establish delete constraint integrity constraint Common constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT […]