08 2013 档案
摘要:1,函数返回值与传入参数#include void foo(void);// 如果不声明返回值类型, 那么返回值类型默认为intbar(void);// 声明没有带参数, 那么调用时可以传递任意参数.void test();//void test1(void);int main(void){ foo(); printf("world.\n"); bar(); test(3.14, "hello", 123); //test1(1, 3.14, "hello"); return 0;}void foo(void){ printf(&qu
阅读全文
摘要:这个仅作为练习扩展使用,贴出代码,作为以后复习,不直接写结果。因为要自己推出#include int main(void){ int score; printf("pls input a score: "); scanf("%d", &score); if (score 100) { printf("wrong. score from 0 to 100.\n"); } else if (60 int main(void){ int i, j; i = 1; while (i int main(void){ ...
阅读全文
摘要:1,if语句 1 #include 2 3 /* 4 *if (expr) 5 * stat 6 *else if (expr) 7 * stat 8 *else 9 * stat10 *11 *expr: expression12 *stat: statement -> expr; | { ... } 13 */14 15 #define EPISILON 0.000000116 17 int main(void)18 {19 double d = 5.0;20 21 // 对浮点数进行判断, 最好给一个判定范围22 /...
阅读全文
摘要:1,九九乘法#include int main(void){ int i, j; for (i = 1; i int main(void){ int a = 3, b = 5; printf("after 0 swap, a = %d, b = %d\n", a, b); printf("------------------\n"); int t; t = a; a = b; b = t; printf("after 1 swap, a = %d, b = %d\n", a, b); printf("------------
阅读全文
摘要:1,sizeof用法以及各个类型占据的字节大小#include int main(void){ char ch; int i; long l; long long ll; float f; double d; long double ld; printf("size of char : %u\n", sizeof(ch)); printf("size of int : %u\n", sizeof(int)); printf("size of long : %u\n", sizeof l); ...
阅读全文
摘要:1. 大小写s的区别,只是多了一个预处理功能,所以后期写关于硬件的汇编使用大写S .s 汇编语言源程序;汇编.S汇编语言源程序;预处理,汇编2.编译过程 A. 预处理 使用cpp gcc -E src.c -o dst.i B. 编译阶段 gcc -S src.i -o dst.s C.汇编阶段 gcc -c src.s -o dst.o D. 链接阶段 gcc -o dst src.o最后执行 ./dst
阅读全文
摘要:.section .rodata .align 2.LC0: .ascii "hello arm\000" .text .align 2 .global mainmain: push {lr} ldr r0, .L3 bl puts pop {lr} mov pc,lr.L3: .word .LC0执行的话也是arm-linux-gcc 1.s -o 1,生成机器可执行文件 1下面为段落做说明:bss段:用来存放程序中未初始化的全局变量的一块内存区域。BSS段属于静态内存分配。data段:用来存放程序中已初始化的全局变量的一块内存区域。数据段属于静态内存分配。text段:用
阅读全文
摘要:输入vim 1.c 编辑c文件will@will-Inspiron-N4010:~/ex/c/1$ vim 1.c按i 进入插入模式,输入一下字符#include int main(void){ printf("hello \n");}输入完成后,Shift + ; 得到命令行,输入wq!,保存强制退出 。运行gcc 1.c -o 1will@will-Inspiron-N4010:~/ex/c/1$ gcc 1.c -o 1生成可执行文件,运行./1 , 即可运行完整程序得到hello
阅读全文

浙公网安备 33010602011771号