c语言
潇授大帝
忙于生存...
展开
-
1.第一个C语言程序
第一个C语言程序新建一个c文件:vi a.c#include <stdio.h>int main(){ printf("hello world!\n"); return 0;}编译c语言程序:cc a.c -> 生成 a.out执行c语言程序:./a.out -> hello world!...原创 2019-07-19 23:37:30 · 99 阅读 · 0 评论 -
9.gdb工具的使用
gdb工具的使用gcc 自带 gdb工具:gcc -v gdb -help使用gdb编译c文件:gcc -g main.c -o main.out使用gdb调试:gdb ./main.out列出源代码:l继续列出源代码:l 或 回车开始调试:start (显示的代码是将要执行的代码,不是已执行的)打印变量:p a (print a)继续执行下一行: n (next)进入查看函数:...原创 2019-07-19 23:44:19 · 99 阅读 · 0 评论 -
8.Linux C语言 初始指针
Linux C语言 初始指针main.c#include <stdio.h>void change(int *a,int *b){ int tmp = *a; *a = *b; *b = tmp;}int main(){ int a = 5; int b = 3; chan...原创 2019-07-19 23:43:46 · 82 阅读 · 0 评论 -
7.打造c语言小程序
打造c语言小程序input.c#include <stdio.h>int main(){ int flag = 1; int num; int count = 0; int sum = 0; while(flag){ scanf("%d",&num); ...原创 2019-07-19 23:43:11 · 108 阅读 · 0 评论 -
6.管道原理及应用
管道原理及应用查看指定目录下包含 'c’的内容:ls /home/xiao/home/ | grep c查看当前在运行的进程:ps -e查看当前在运行的进程包含’ssh’的进程:ps -e | grep ssh...原创 2019-07-19 23:42:40 · 219 阅读 · 0 评论 -
5.输入输出流和错误流
输入输出流和错误流输入流:stdinint a;scanf("%d",&a);fscanf(stdin,"%d",&a);输出流:stdoutprintf("xiao\n");fprintf(stdout,"xiao\n");错误流:stderrfprintf(stderr,"error! value must > 0");return 1;注:s...原创 2019-07-19 23:40:48 · 382 阅读 · 0 评论 -
4.main函数
main函数#include <stdio.h>int main(int argv,char* argc[]){ printf("hello world\n"); printf("atgv is %d \n",argv); int i; for (i=0;i<argv;i++){ print...原创 2019-07-19 23:40:14 · 111 阅读 · 0 评论 -
3.makeFile的编写
makeFile的编写检查make是否安装:make -v安装make:sudo apt-get install make建立makefile文件:vi Makefile#this is make filehello.out:max.o min.o hello.c gcc max.o min.o hello.c -o hello.outmax.o:max.c ...原创 2019-07-19 23:39:44 · 94 阅读 · 0 评论 -
2.多个源文件分而治之
hello.c#include <stdio.h>#include "max.h"#include "min.h"int main(){ int a1 = 5; int a2 = 10; int maxnum = max(a1,a2); int minnum = min(a1,a2); printf("最大数字是:%d\n",maxnum); printf("最...原创 2019-07-19 23:38:58 · 74 阅读 · 0 评论 -
10.内存管理与函数指针
系统内核栈 (局部变量)(先进后出,后进先出,越往后地址越小。)堆数据段 (全局变量、常量、静态变量)代码段 (越往后地址越大)函数调用及操作记录在栈里编译后的代码被保存在代码段变量的本质是内存指针的本质是地址p &a -> 找到内存地址 (a是变量)p func -> 打印func地址本身 (func是地址)p *func -> 通过地址...原创 2019-07-19 23:45:04 · 62 阅读 · 0 评论