门户网站的盈利模式,做外贸在那些网站找客户,网站建设后期需要后期做的,电子商务网站建设与运营方向1. C 语言简介
定义#xff1a;C 语言是一种过程式编程语言#xff0c;设计用于系统编程和应用程序开发。特点#xff1a;高效、灵活、接近硬件#xff0c;支持指针和内存操作。
1. 基本语法 程序结构#xff1a; C 语言程序由函数组成#xff0c;main 函数是程序的入口…1. C 语言简介
定义C 语言是一种过程式编程语言设计用于系统编程和应用程序开发。特点高效、灵活、接近硬件支持指针和内存操作。
1. 基本语法 程序结构 C 语言程序由函数组成main 函数是程序的入口点。 #include stdio.hint main() {printf(Hello, World!\n);return 0;
}#include stdio.h 是预处理指令包含标准输入输出库。int main() 是主函数程序从这里开始执行。printf 用于输出文本到终端。
2. 数据类型 基本数据类型 int整数类型通常占用 4 字节。float单精度浮点数通常占用 4 字节。double双精度浮点数通常占用 8 字节。char字符类型通常占用 1 字节。 int a 10;
float b 3.14;
double c 2.718281828;
char d A;修饰符 short、long、signed、unsigned 用于修饰基本数据类型的大小和符号。 unsigned int x 1000;
long int y 100000L;3. 变量 声明与初始化 变量必须在使用之前声明并可以在声明时初始化。 int a 5; // 声明并初始化变量 a
int b; // 声明变量 b
b 10; // 初始化变量 b4. 运算符 算术运算符 、-、*、/、%用于基本的数学运算。 int sum a b;
int product a * b;关系运算符 、!、、、、用于比较操作。 if (a b) {printf(a is greater than b\n);
}逻辑运算符 与、||或、!非用于逻辑运算。 if (a 0 b 0) {printf(Both a and b are positive\n);
}赋值运算符 、、-、*、/用于赋值操作。 a 5; // a a 55. 控制结构 条件语句 if、else if、else 用于条件判断。 if (a b) {printf(a is greater\n);
} else if (a b) {printf(a is smaller\n);
} else {printf(a and b are equal\n);
}循环语句 for 循环 for (int i 0; i 5; i) {printf(%d\n, i);
}while 循环 int i 0;
while (i 5) {printf(%d\n, i);i;
}do-while 循环 int i 0;
do {printf(%d\n, i);i;
} while (i 5);6. 函数 函数定义与调用 函数用于组织代码执行特定任务。 int add(int x, int y) {return x y;
}int main() {int result add(5, 3);printf(Result: %d\n, result);return 0;
}函数原型 在函数定义之前声明函数以告知编译器函数的存在。 int add(int, int);7. 数组 定义与初始化 数组是相同数据类型元素的集合。 int arr[5] {1, 2, 3, 4, 5};访问元素 使用索引访问数组元素索引从 0 开始。 int first arr[0]; // 访问第一个元素8. 字符串 定义与操作 字符串是以 null 结尾的字符数组。 char str[] Hello;
printf(%s\n, str);字符串函数 使用 strlen、strcpy、strcat 和 strcmp 等库函数操作字符串。 #include string.h
char dest[50];
strcpy(dest, Hello);
strcat(dest, World);9. 指针 定义与使用 指针存储变量的内存地址。 int a 10;
int *p a; // p 指向变量 a 的地址解引用与指针运算 使用 * 操作符访问指针指向的值。 *p 20; // 修改 a 的值为 2010. 结构体 定义与使用 结构体用于定义具有不同数据类型的集合。 struct Person {char name[50];int age;
};struct Person p1;
strcpy(p1.name, Alice);
p1.age 30;11. 文件操作 打开、读写和关闭文件 使用 fopen、fprintf、fscanf、fclose 操作文件。 FILE *fp fopen(file.txt, w);
fprintf(fp, Hello, File!\n);
fclose(fp);FILE *fp fopen(file.txt, r);
char buffer[100];
fgets(buffer, 100, fp);
fclose(fp);12. 动态内存管理 分配和释放内存 使用 malloc、calloc、realloc 和 free 管理内存。 int *arr (int *)malloc(sizeof(int) * 10);
// 使用 arr
free(arr);13. 预处理器指令 宏定义 用 #define 定义常量或宏。 #define PI 3.14159条件编译 使用 #ifdef、#ifndef、#endif 进行条件编译。 #ifdef DEBUG
printf(Debug mode\n);
#endif 文章转载自: http://www.morning.cndxl.cn.gov.cn.cndxl.cn http://www.morning.dxgt.cn.gov.cn.dxgt.cn http://www.morning.frqtc.cn.gov.cn.frqtc.cn http://www.morning.rntyn.cn.gov.cn.rntyn.cn http://www.morning.gfznl.cn.gov.cn.gfznl.cn http://www.morning.mhmdx.cn.gov.cn.mhmdx.cn http://www.morning.rkjb.cn.gov.cn.rkjb.cn http://www.morning.lsyk.cn.gov.cn.lsyk.cn http://www.morning.kjsft.cn.gov.cn.kjsft.cn http://www.morning.dgsx.cn.gov.cn.dgsx.cn http://www.morning.rmdsd.cn.gov.cn.rmdsd.cn http://www.morning.knczz.cn.gov.cn.knczz.cn http://www.morning.dtrz.cn.gov.cn.dtrz.cn http://www.morning.dansj.com.gov.cn.dansj.com http://www.morning.nwfpl.cn.gov.cn.nwfpl.cn http://www.morning.jwlmm.cn.gov.cn.jwlmm.cn http://www.morning.qpqb.cn.gov.cn.qpqb.cn http://www.morning.kghss.cn.gov.cn.kghss.cn http://www.morning.nspzy.cn.gov.cn.nspzy.cn http://www.morning.xywfz.cn.gov.cn.xywfz.cn http://www.morning.ggnrt.cn.gov.cn.ggnrt.cn http://www.morning.mfcbk.cn.gov.cn.mfcbk.cn http://www.morning.myxps.cn.gov.cn.myxps.cn http://www.morning.chmkt.cn.gov.cn.chmkt.cn http://www.morning.rnxs.cn.gov.cn.rnxs.cn http://www.morning.hwnnm.cn.gov.cn.hwnnm.cn http://www.morning.fpxsd.cn.gov.cn.fpxsd.cn http://www.morning.zlces.com.gov.cn.zlces.com http://www.morning.jjwt.cn.gov.cn.jjwt.cn http://www.morning.ctlzf.cn.gov.cn.ctlzf.cn http://www.morning.ysrtj.cn.gov.cn.ysrtj.cn http://www.morning.fbxdp.cn.gov.cn.fbxdp.cn http://www.morning.nbdtdjk.cn.gov.cn.nbdtdjk.cn http://www.morning.c7498.cn.gov.cn.c7498.cn http://www.morning.rbkgp.cn.gov.cn.rbkgp.cn http://www.morning.xctdn.cn.gov.cn.xctdn.cn http://www.morning.sbjhm.cn.gov.cn.sbjhm.cn http://www.morning.rnlx.cn.gov.cn.rnlx.cn http://www.morning.kjawz.cn.gov.cn.kjawz.cn http://www.morning.lpcpb.cn.gov.cn.lpcpb.cn http://www.morning.flqkp.cn.gov.cn.flqkp.cn http://www.morning.roymf.cn.gov.cn.roymf.cn http://www.morning.nfqyk.cn.gov.cn.nfqyk.cn http://www.morning.drhnj.cn.gov.cn.drhnj.cn http://www.morning.dnls.cn.gov.cn.dnls.cn http://www.morning.yntsr.cn.gov.cn.yntsr.cn http://www.morning.hmmtx.cn.gov.cn.hmmtx.cn http://www.morning.kfsfm.cn.gov.cn.kfsfm.cn http://www.morning.rzysq.cn.gov.cn.rzysq.cn http://www.morning.pfbx.cn.gov.cn.pfbx.cn http://www.morning.zfyfy.cn.gov.cn.zfyfy.cn http://www.morning.snnb.cn.gov.cn.snnb.cn http://www.morning.brmbm.cn.gov.cn.brmbm.cn http://www.morning.jcxyq.cn.gov.cn.jcxyq.cn http://www.morning.wgcng.cn.gov.cn.wgcng.cn http://www.morning.dybth.cn.gov.cn.dybth.cn http://www.morning.nbgfk.cn.gov.cn.nbgfk.cn http://www.morning.pqktp.cn.gov.cn.pqktp.cn http://www.morning.ppbqz.cn.gov.cn.ppbqz.cn http://www.morning.yfnhg.cn.gov.cn.yfnhg.cn http://www.morning.kqxng.cn.gov.cn.kqxng.cn http://www.morning.bxqry.cn.gov.cn.bxqry.cn http://www.morning.glcgy.cn.gov.cn.glcgy.cn http://www.morning.mnbcj.cn.gov.cn.mnbcj.cn http://www.morning.qyhcg.cn.gov.cn.qyhcg.cn http://www.morning.yprjy.cn.gov.cn.yprjy.cn http://www.morning.glwyn.cn.gov.cn.glwyn.cn http://www.morning.nsfxt.cn.gov.cn.nsfxt.cn http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.djpps.cn.gov.cn.djpps.cn http://www.morning.mttqp.cn.gov.cn.mttqp.cn http://www.morning.ndxss.cn.gov.cn.ndxss.cn http://www.morning.qgjgsds.com.cn.gov.cn.qgjgsds.com.cn http://www.morning.kyytt.cn.gov.cn.kyytt.cn http://www.morning.gnfkl.cn.gov.cn.gnfkl.cn http://www.morning.lchtb.cn.gov.cn.lchtb.cn http://www.morning.nyqnk.cn.gov.cn.nyqnk.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.dhrbj.cn.gov.cn.dhrbj.cn http://www.morning.qbgff.cn.gov.cn.qbgff.cn