当前位置:网站首页>C语言从入门到入土(一)
C语言从入门到入土(一)
2022-07-24 05:16:00 【泡泡牛奶】
1、第一个C语言程序
学习C语言首先要知道C语言的基础框架
这是标准C语言标准的主函数写法(需要牢记)
#include <stdio.h>
int main()
{
//语句
return 0;
}而在有一些书本上会看到下面两种写法
#include <stdio.h>
void main()
{
//语句
}#include <stdio.h>
main()
{
//语句
}这些都是比较早期的写法,可以认识一下
理解:c语言是以个房子,main函数相当是一扇大门(主门),PS:会有侧门(这个相当于自定义函数),但要使用这些侧门,总要先踏入主门吧
2、数据类型
| 类型 | 表示 | 所访问的字节大小 单位 ( 比特 - bit - B) | 输出格式 |
| char | 字符型 | 1 | %c / %s (字符串) |
| short | 短整型 | 2 | %hd |
| int | 整型 | 4 | %d |
| long | 长整型 | 4 | %ld |
| long long | 长长整型 | 8 | %lld |
| float | 单精度浮点型 | 4 | %f |
| double | 双精度浮点型 | 8 | %lf |
在早期学习C语言的时候主要认识这些就可以了
3、常量与变量
3.1、什么是 常量?变量?
(1)常量
在C语言中,经常用不变的值来表示常量
例如:
3.14;
2022;
666;(2)变量
同理,在C语言中,随时可能会变的值就是变量
在C语言中,要使用变量,首先要知道你将要使用的变量的类型,然后再为这个变量取个名字
例如:
int i; //定义的是一个 类型为 整型 ,名字为 i 的变量
char ch;//定义的是一个 类型为 字符型 ,名字为 ch 的变量3.2、定义变量的表示方法
int i = 1;//为 变量i 初始化为 1
char ch = 'a';//为 变量ch 初始化为字符 a3.3、变量的分类
(1)全局变量
理解:在 大括号 { } 外面的变量就是全局变量
(2)局部变量
理解:在 大括号 { } 里面的变量就是局部变量
(3)注意:
1、变量必须在前面(无论是全局还是局部)
2、同一个变量名不能重复定义
3、当全局变量的名字与局部变量的的名字相同时,优先局部变量
示例如下:

结语
好啦,本期就到这里,希望大家都能实现自己的目标,好好加油,努力实现更上一层,我们下期再见,拜拜

边栏推荐
- Jsp+dao integration
- Learning some contents of vector and iterator
- View progress!!! RPM installation!!!
- 13. Write a program, in which a user-defined function is used to judge whether an integer is a prime number. The main function inputs a number and outputs whether it is a prime number.
- Performance test process
- Web development
- Embedded system transplantation [2] - Construction of cross development environment
- NFS shared services
- 求网络的flops
- 【常用技巧】
猜你喜欢

Teach you how to weld CAD design board bottom (for beginners) graphic tutorial

Binary SCA fingerprint extraction black Technology: go language Reverse Technology

C语言入门篇 三.数组 四.操作符

Introduction to threads

手写orm框架

PPPoE gateway simulation environment setup

关于numpy基础用法的一个整理

JMeter FAQs

PXE efficient batch network installation

JSP+Dao整合
随机推荐
Scikit learn -- steps of machine learning application development
1、基于增量式生成遮挡与对抗抑制的行人再识别
使用swagger2markup生成API文档
Introduction to 51 single chip microcomputer (dedicated to the most understandable article for beginners)
Installation and login login
【深度学习】(三)图像分类
scikit-learn笔记
Generics and annotations
The fourth job: about the usage of cat, grep, cut, sort, uniq, VIM, TR and other commands
anaconda常用命令的整理
PPPoE gateway simulation environment setup
c2-随机产生函数种子seed、numpy.random.seed()、tf.random.set_seed学习+转载整理
Do you want to have a robot that can make cartoon avatars in three steps?
Chapter5 foundation of deep learning
明星逆市入局的NFT,如何能走出独立行情?
【STL】Map &unordered_map
csgo部分常用服务器指令与一些绑定指令整理
泛型和注解
Generator generator, which generates only two methods
C语言进阶篇 三.字符串函数和内存操作函数