前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C编程基础-基础篇 1

C编程基础-基础篇 1

原创
作者头像
未来最可爱的人
修改2021-02-25 15:30:43
2600
修改2021-02-25 15:30:43
举报
文章被收录于专栏:编程基础

语言作者

丹尼斯·里奇(Dennis MacAlistair Ritchie)

注释

单行注释

代码语言:txt
复制
//单行注释

多行注释

代码语言:txt
复制
/*多行注释*/

变量

命名规则

字母数字下划线,不能以数字开头,不能使用单个下划线

变量类型

类型

空间

char

1 byte

unsigned char

1 byte

short

2 bytes

unsigned short

2 bytes

int

4 bytes

unsigned int

4 bytes

long

8 bytes

unsigned long

8 bytes

float

8 bytes

double

8 bytes

long double

10 bytes

常量

定义常量

代码语言:txt
复制
#define PI 3.14159
代码语言:txt
复制
const float PI = 3.14159;

标准输入

scanf
代码语言:txt
复制
#include <stdio.h>

int main() {
    int count, i;
    count = scanf("%d", &i);
    printf("you input %d number, the number is %d\n", count, i);

    return 0;
}
代码语言:txt
复制
1
you input 1 number, the number is 1
fgets
代码语言:txt
复制
#include <stdio.h>

int main() {
    char str[20];
    fgets(str, 20, stdin);
    printf("%s", str);

    return 0;
}
代码语言:txt
复制
1
1

标准输出

printf
代码语言:txt
复制
#include <stdio.h>

int main() {
    printf("welcome to our lessons!\n");

    return 0;
}
代码语言:txt
复制
welcome to our lessons!
puts
代码语言:txt
复制
#include <stdio.h>

int main() {
    puts("welcome to our lessons!");

    return 0;
}
代码语言:txt
复制
welcome to our lessons!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
目录
  • 语言作者
  • 注释
    • 单行注释
      • 多行注释
      • 变量
        • 命名规则
          • 变量类型
          • 常量
            • 定义常量
              • 标准输入
                • scanf
                • fgets
              • 标准输出
                • printf
                • puts
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档