当前位置:网站首页>2. First knowledge of C language (2)
2. First knowledge of C language (2)
2022-07-06 13:43:00 【It's Wang Jiujiu】
First time to know C Language (2)
Catalog
VS Installation and creation project of
VS Installation and creation project of
install
Microsoft visual studio It is very easy to use programming software , among community The version is free , It is very suitable for beginners .
at present VS Updated to 2022 edition , The official website is as follows :
Visual Studio: IDE and Code Editor for Software Developers and TeamsVisual Studio dev tools & services make app development easy for any developer, on any platform & language. Develop with our code editor or IDE anywhere for free.https://visualstudio.microsoft.com/ The installation process is not complicated , It is recommended to choose the default installation path .
Create project
function VS2022, Click on the right to create a new project .
Select empty item , Click next .
Enter the project name , Choose the path to save the project , The path here is recommended to be changed manually , Set it in the folder you can find , Click next .
An empty project is generated , Right click the source file —— add to —— New item
choice C++ file , Because we're using C Language , Note that the suffix of the name should be changed to .c, Click Add .
An empty source file is generated , The same is true if you create a new header file .
newc++.cpp File settings
VS After installed , If we start writing programs at this time , May come across scanf The reason for the error of wait function
for example :
#include<stdio.h>
int main()
{
int a = 0;
scanf("%d", &a);
return 0;
}
Running the above code will report an error :
error C4996: 'scanf': This function or variable may be unsafe. Consider usingscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Here the compiler thinks scanf It's not safe , It is recommended that we use scanf_s Instead of , Or define in the first line of code _CRT_SECURE_NO_WARNINGS.
The first method is only in VS When used in , yes VS Self defined . Here we use the second method , Add #define _CRT_SECURE_NO_WARNINGS that will do .
But it is very troublesome to add the source file manually every time you open it , How can it be done once and for all ?
The method is as follows :
Right click VS Icon , Click properties —— Where to open the file .
Search in the folder newc++, Find the suffix .cpp The file of .
Right click , Open mode —— Notepad , take #define _CRT_SECURE_NO_WARNINGS Paste it into the text and save it , Choose to overwrite the original file when saving .
If an error is reported, it shows that you have no permission , Don't be nervous .( Most students' computers will have such problems )
Method 1 : Create a new notepad on the desktop , Right click —— Run as an administrator , Open and paste our code into the text , Rename the text to newc++file.cpp And then to VS Overwrite the original file under the installation directory .( recommend win10 Using this method )
Method 2 : look for newc++file.cpp The folder where the file is located , Make a copy of the document , Paste it on the desktop .( recommend win11 Using this method )
Right click the file copied on the desktop , Choose how to open —— Text ( use VS Open it ), Paste the above code , preservation .
Then drag and drop the files on the desktop to the original folder , The system will prompt whether to overwrite , Choice is .
Prompt that administrator permission is required ,win11 The administrator permission of home edition is turned on by default , Click ok .
Then create a new source file every time , This line of code will be automatically added in the first line , You don't have to add it manually , Very convenient .
It's suggested that you should be in VS After installation , take newc++.cpp The file is set , Especially for beginners , It can avoid many unnecessary bug appear .
边栏推荐
- The difference between overloading and rewriting
- Principles, advantages and disadvantages of two persistence mechanisms RDB and AOF of redis
- 1.C语言初阶练习题(1)
- (原创)制作一个采用 LCD1602 显示的电子钟,在 LCD 上显示当前的时间。显示格式为“时时:分分:秒秒”。设有 4 个功能键k1~k4,功能如下:(1)k1——进入时间修改。
- 深度强化文献阅读系列(一):Courier routing and assignment for food delivery service using reinforcement learning
- Detailed explanation of redis' distributed lock principle
- 魏牌:产品叫好声一片,但为何销量还是受挫
- About the parental delegation mechanism and the process of class loading
- [modern Chinese history] Chapter V test
- Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
猜你喜欢
3.输入和输出函数(printf、scanf、getchar和putchar)
【手撕代码】单例模式及生产者/消费者模式
(original) make an electronic clock with LCD1602 display to display the current time on the LCD. The display format is "hour: minute: Second: second". There are four function keys K1 ~ K4, and the fun
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
Reinforcement learning series (I): basic principles and concepts
The latest tank battle 2022 full development notes-1
魏牌:产品叫好声一片,但为何销量还是受挫
凡人修仙学指针-1
一段用蜂鸣器编的音乐(成都)
Leetcode. 3. Longest substring without repeated characters - more than 100% solution
随机推荐
6. Function recursion
List set map queue deque stack
js判断对象是否是数组的几种方式
Arduino+ water level sensor +led display + buzzer alarm
简述xhr -xhr的基本使用
Custom RPC project - frequently asked questions and explanations (Registration Center)
2022泰迪杯数据挖掘挑战赛C题思路及赛后总结
Comparison between FileInputStream and bufferedinputstream
3. Input and output functions (printf, scanf, getchar and putchar)
仿牛客技术博客项目常见问题及解答(二)
受检异常和非受检异常的区别和理解
The difference between cookies and sessions
Leetcode.3 无重复字符的最长子串——超过100%的解法
C language to achieve mine sweeping game (full version)
[hand tearing code] single case mode and producer / consumer mode
[modern Chinese history] Chapter 9 test
The latest tank battle 2022 full development notes-1
编写程序,模拟现实生活中的交通信号灯。
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
[modern Chinese history] Chapter 6 test