c语言的结构体,常量和编译一个可执行文件

 首先你要安装MinGW32

其实就配好环境变量就好了,具体去百度啦!

进入我来写你来看模式

mian.c文件

#include <stdio.h>
#include "b.h"

int main(){
int m = 5;
int n = 6;
int result = b(m,n);
printf("hello
");
}
#endif

b.c文件

#include "b.h"
int b(int a ,int b) {
return a - b;
}

b.h头文件

//防止文件重复引用,就是两个文件都用上了这个头文件
#ifndef b_Header
#define b_Header
int b(int a,int b);

#endif

那我来讲一下#include <stdio.h>是啥把 #是预备的意思

这里呢把stdio.h(系统的函数)用<>这个来导入#include

"b.h" 中的b.h用""导入,因为是你自己写的!

1. -c 编译为目标文件
2. -E 只进行预处理
3. -o 设定生成的文件

用那个gcc -c main.c -o main.o 把main.c编写成2进制的main.o文件

用gcc main.c  b.c 进行编译

 1. 头文件可以不需要编译 

2.可以查看具体的声明 
3.头文件加上实现文件的o文件提交给使用者即可,不需要知道源代码 
4.o文件预先编译,所以整个项目编译时,会大大提高编译的时间 。 
5. 当一个文件(A.c文件)依赖于头文件(b.h)时,如果b.c编译之后形成的b.o文件重新编译后,a.o的文件不需要重新编译

  定义常量,结构体

#include <stdio.h>

#define PI 3.14 // 常量

#define area(a,b) a*b;

//typedef 用法就是相当于一个别名
typedef int cj ;

//结构类型数据
struct person {
int age;
float height
}; 

//一般只用一次
struct {
int age;
float height
}person ;

//类型
typedef struct Emp{
int age;

} employee; 
//
typedef struct{
int age;

} Employee;

int main(){
  int m = 5;
  int n = 6;
  cj a=5;
  int arry[] ={1,2,3};

  //取结构体
    struct person p1;

  //用结构体
   p1.age=20;


}

 

栈: stack 先进后出 储存数据 ,空间不变

堆: hoop 内存区域 存数据要长久的,数据大的,可以动态增加,

原文地址:https://www.cnblogs.com/kangniuniu/p/4921656.html