当前位置:网站首页>C language tutorial (1) - preparation
C language tutorial (1) - preparation
2022-07-31 05:45:00 【Why are so many names taken?】
To start learning C language, you generally need to prepare:
- linux virtual machine download virtual machine
- gcc compiler (usually comes with linux)
As for how to install a virtual machine Baidu Yiyi I won’t say too much here.
So, how do you use a virtual machine?This requires some commands.
Right-click on the desktop, click open the terminal, you can enter commands in this interface.
Here are a few basic commands:
- mkdir + directory name create directory
- rm + filename delete file
- ls list files
- cp + file to copy + file after copy copy file
- ...
The basic usage of these commands can be obtained with the man command.
such as man mkdir
If you want to write c code, you can use the vi editor.Note that the c code ends with .c
vi + filename write file
vi has three modes:
- Command Mode
- Edit Mode
- Last line mode
The command mode is entered at the beginning, and no code can be written.At this point, click the "i" key to enter edit mode.In edit mode, you can write code.
Enter the following code in edit mode:
#includeint main(void){printf("Hello World");return 0;} For the explanation of this code, we will gradually understand it later.in here
int main(void){return 0;}It is often a framework for C code.
I believe everyone has experienced the pain of losing files without saving.So, how do we save the code we write?
First, we need to hit the Esc key to switch from edit mode to command mode.Then, click the ":" key to switch from command mode to last line mode.In the last line mode, enter wq to save and exit.
- w: save
- q: quit without saving
So, how to run this program?
After exiting vi, we are back where we entered the command before.In it, enter
gcc + filenameAt this time, gcc will preprocess the c code (source file) we wrote (will be discussed later) and compile it to generate an executable file, the default is "a.out", to run the executable file, you need to input: ./+ filename.Running our "a.out", we can type
./a.outCan I change the name of the executable to b.out?
The first method:
mv a.out b.outWhat is mv?Enter the following command to view.
man mvThe second method, when generating the executable file, enter
gcc filename -o b.outIn this way, b.out can be directly generated as an executable file.
In addition, since man comes out in baby language, so Baidu translation
边栏推荐
- 12 【网页布局总结 元素的显示与隐藏】
- PAT_乙级_真题练习_1007_素数对猜想
- 数据库上机实验6 数据库完整性
- 03 【数据代理 事件处理】
- Flask-based three-party login process
- About the problems encountered by Xiaobai installing nodejs (npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)
- 10 【组件编码流程 组件自定义事件 全局事件总线】
- leetcode-829. 连续整数求和(数论)
- The process and specific code of sending SMS verification code using flask framework
- Redis的初识
猜你喜欢
随机推荐
win11中利用IIS10搭建asp网站
Access数据库的查询
04 【计算属性 侦听属性】
Object Detection Study Notes
代码块、Package,Import,封装(第六天)
Distributed transaction processing solution big PK!
局部变量成员变量、引用类型、this,static(第五天)
Swordsman Offer Special Assault Edition --- Day 3
Sword Point Offer Special Assault Edition ---- Day 1
If the account number or password is entered incorrectly for many times, the account will be banned.
gin框架学习-JWT认证
leetcode-每日一题565. 数组嵌套(标记图和并查集)
07 【内置指令 自定义指令】
Quickly master concurrent programming --- the basics
代码执行漏洞
剑指offer基础版 ---- 第29天
第7章 网络层第2次练习题答案(第三版)
Proteus 8 Professional安装教程
PHP中abstract(抽象)、final(最终)和static(静态)原理与用法
剑指offer专项突击版 ---- 第2天









