当前位置:网站首页>初始c语言时的一些知识
初始c语言时的一些知识
2022-06-25 12:35:00 【LIn_jt】
前言
在学习c语言时,我们会对c语言的各个分类知识进行大致的理解,本文将介绍几种分类的知识(后续将继续补充)
正文
一.第一个c语言程序,请看下图

此处的main函数为程序的入口,一个工程中有且仅有一个main函数。
而第6行的printf函数为打印函数,即在屏幕上输出“ ”之间的内容,程序的结果为:

二.数据类型
1.数据类型是为了定义变量的时候使用,c语言主要提供了以下数据类型:

2.各个数据类型所占的空间
请看以下程序:

此处的sizeof关键字,意为计算一个对象所占的内存的大小,单位为byte,以下为其输出结果:

1 2 4 4 8 4 8(按照上图顺序)即为各个数据类型所占的内存大小。
三.变量与常量
1.变量
变量从字面意思上即为可变的量,而定义变量的方法如下图所示:

(建议在创建变量的时候为变量赋初值。)
2.变量的分类
变量分为两种,一种为局部变量,一种为全局变量。
对于局部变量:即为定义在大括号(代码块)内的变量即为局部变量。
对于全局变量:定义在大括号之外的变量即为全局变量,请看下图:

by the way:当局部变量与全局变量的变量名相同时,局部变量优先:
例:

以上即为初始c语言的知识的一部分内容,后续将会继续更新!
边栏推荐
- 关于数据在内存中存储的相关例题
- Native JS --- infinite scrolling
- 康威定律,作为架构师还不会灵活运用?
- Optimization of lazyagg query rewriting in parsing data warehouse
- Lexical trap
- Conway's law can not be flexibly applied as an architect?
- Maui's learning path (II) -- setting
- Heavyweight live | bizdevops: the way to break the technology situation under the tide of digital transformation
- 德国举行全球粮食安全团结会议
- Jenkins pipeline uses
猜你喜欢

MySQL writes user-defined functions and stored procedure syntax (a detailed case is attached, and the problem has been solved: errors are reported when running user-defined functions, and errors are r

《MongoDB入门教程》第01篇 MongoDB简介

Sword finger offer day 3 string (simple)

剑指Offer 第 2 天链表(简单)

剑指 Offer II 025. 链表中的两数相加

Conway's law can not be flexibly applied as an architect?
Module 5 (microblog comments)

WIN10环境下配置pytorch

Solution to Nacos' failure to modify the configuration file mysql8.0

Koa frame
随机推荐
À propos du stockage des données en mémoire
Sword finger offer 04 Find in 2D array
关于数据在内存中存储的相关例题
剑指offer 第 3 天字符串(简单)
二叉树之_哈夫曼树_哈弗曼编码
Meichuang was selected into the list of "2022 CCIA top 50 Chinese network security competitiveness"
坡道带来的困惑
Reload cuda/cudnn/pytorch
1024水文
MySQL learning notes
It's an artifact to launch a website in a few minutes
mysql导入导出数据到excel表日期出现问题
Common colors for drawing
Alibaba stability fault emergency handling process
It is extraordinary to make a move, which is very Oracle!
[data visualization] 360 ° teaching you how to comprehensively learn visualization - Part 1
Summary of leetcode linked list problem solving skills
leetcode - 384. 打乱数组
1251- Client does not support authentication protocol MySql错误解决方案
QT display ffmpeg decoded pictures