C语言
分享C语言的各种训练代码,与你们一起探索C语言的奥秘
书中藏着宇宙
深圳大学硕士,信息与通信工程专业研究僧一枚,热爱学术的学术垃圾,喜欢技术的技术菜狗,
展开
-
Linux多线程网络通信
Linux下多线程TCP通信原创 2023-10-05 21:14:21 · 202 阅读 · 0 评论 -
Linux的socket通信
socket通信的Linux实践实现原创 2023-09-24 17:13:58 · 349 阅读 · 0 评论 -
C语言的链表的相关操作
C语言链表相关操作原创 2023-08-12 16:05:57 · 210 阅读 · 0 评论 -
C 语言多线程(上)
C语言多线程操作(上)原创 2023-08-01 10:56:29 · 344 阅读 · 0 评论 -
C/C ++指针传递下,原本值的变换情况分析
指针传递情况下的,原本传递值的变化情况分析(图文并茂,通俗易懂)原创 2023-05-27 20:53:29 · 58 阅读 · 0 评论 -
C++的默认参数和占位参数
C++的默认参数和占位参数原创 2023-01-09 22:01:15 · 635 阅读 · 3 评论 -
C++通讯录管理系统
基于C++的分立文件编写的通讯录管理系统原创 2023-01-03 20:56:07 · 426 阅读 · 0 评论 -
【C语言对链表的操作(链表的初始化,建立,求长,增加,删除,以及输出)】
C语言对链表的操作(链表的初始化,建立,求长,增加,删除,以及输出)原创 2022-07-22 17:19:07 · 2456 阅读 · 0 评论 -
【C语言对数据文件的顺序读写】
C语言对于文件顺序的读写原创 2022-07-09 20:43:41 · 493 阅读 · 0 评论 -
基于STM32单片机的步数测量系统(免费开源)
步数测量系统原创 2022-06-01 10:57:57 · 8042 阅读 · 16 评论 -
C语言对枚举类型的使用【枚举类型】
//对于枚举类型的使用/*枚举类型定义enum[枚举名] {枚举元素表} C语言对于枚举类型当做常量处理 默认枚举元素里面从0开始*/#include <stdio.h>enum color {red,yellow,blue,pink,black}i,j,k,temp;//枚举常量void print(enum color m);//枚举常量做函数参数void main(){ int n=0; //三次循环,检测三个不同颜色方案 for(i=red;i<原创 2022-03-24 10:52:36 · 782 阅读 · 0 评论 -
C语言对联合体的使用【共用体】
/*联合体和共用的练习*///联合体的练习#include <stdio.h>typedef struct{ int num; char sex; char name[10]; char job; union { int clas_s; char position[5]; }category;} Person_information;Person_information person[3];voi原创 2022-03-24 09:54:51 · 880 阅读 · 0 评论 -
C语言对动态链表的使用
#include <stdio.h>#include <stdlib.h>#define LEN sizeof(struct Student) //宏定义为LEN为Struct Student的长度int n=0; //声明为全局变量,任何函数都可以使用struct Student{ int num; float score; struct Student *next;//next是指针类型变量,指向原创 2022-03-19 21:54:03 · 867 阅读 · 0 评论 -
C语言对链表的使用【静态链表】
//对于数据链表的使用#include <stdio.h>struct Student{ int num; float score; struct Student *next;//next是指针类型变量,指向结构体类型}stu1,stu2,stu3,*head,*p;//定义了三个struct Studen类型的变量,作为链表的节点 int main() { int i=1; printf("请你输入各个学生的信息\n"); scanf("原创 2022-03-18 11:03:07 · 1001 阅读 · 0 评论 -
指向结构体的指针
#include <stdio.h>//分数结构体struct Score{float chinese ;float math ;float english;};//Student 结构体数组struct Student{ int num; char name[10]; struct Score score ;//score属于struct Score类型}stu[3];void input (struct Student stu[]);voi.原创 2022-03-10 22:34:28 · 113 阅读 · 0 评论 -
指向结构体的指针
/*指向结构体变量的指针*//*Copyright @ mawei谭浩强第五版C语言*/#include <stdio.h>struct Student //Student 结构体{ int num; char name[10]; float score ;}stu1,stu2; //define two struct variables : stu1,stu2;struct Student * p1,*p2;//definition o原创 2022-03-10 21:34:53 · 100 阅读 · 0 评论 -
【C语言对于结构体的使用】
/*study structure*/#if(0)//conditional compilation #include <stdio.h>void main(){ struct Student { int num ; char name[10]; float score; }Student1,student2; scanf("%d %s %f",&Student1.num,&Student原创 2022-03-06 12:31:35 · 418 阅读 · 0 评论 -
测井深度信号发生器
#include <reg51.h>#define unit unsigned int//用unit代替unsigned unit变量类型#define uchar unsigned char//replace unsigned unit with unitsbit Key1 =P2^0;sbit Out1 =P1^0;sbit Out2 =P1^1;unit flag=1;//标志位unit tt=0;//相位差控制位unsigned int Wave_time;//波...原创 2022-03-01 14:47:15 · 361 阅读 · 4 评论 -
C语言返回值为指针类型的函数
重点:返回值Wie指针类型与返回值为整型和浮点型一样,只不过它的返回值为指针类型,即地址。/*a个学生的b门成绩指定输出指定学生的成绩*/#include <stdio.h>float array_a[3][4];int main(){ void Input(float array[3][4],int m ,int n); float * search(float (*pointer)[4],int n); float *p; int i; I原创 2022-02-24 22:41:52 · 926 阅读 · 0 评论 -
C语言指向函数的指针做参数
要点:用函数的入口地址作为参数传递到其他函数。这样子可以实现对函数的调用,这是函数除了函数名调用以外的第二种调用方式#include <stdio.h>#include <math.h>int add(int a ,int b){ return a+b;}int subtraction(int a,int b){ return abs(a-b);}int Multiply(int a,int b){ return a*b;}in原创 2022-02-16 16:34:16 · 282 阅读 · 0 评论 -
C语言指向函数的指针
要点:在程序中定义一段函数,编译器会给函数的源代码转换为可执行代码并分配相应的存储空间。这段存储空间就会有一段地址,函数名就是起始地址。可以用函数类型的指针,指向某个函数起始地址就可以实现该函数的调用其定义个格式如下:float (*p)(float a,float b,…float n)这时P指针就是一个指向有n个参数的,返回值为float类型的函数。#include <stdio.h>int main(){ float Max(float a ,float b); flo原创 2022-02-15 21:21:19 · 189 阅读 · 0 评论 -
字符指针做函数参数
(1)用字符数组名做函数参数/*使用字符指针作为函数参数 Use character Pointers as function argument*/#include <stdio.h>int main(){ char a[]="shu zhong jia zhe yu zhou" ; char b[]="xin nian kuai le "; char c[30]; char d[30]; void String_Copy(char firs原创 2022-02-15 16:40:53 · 964 阅读 · 0 评论 -
C语言字符型指针对字符串的输出
使用字符类型的指针对字符串的输出`/*利用指针实现对字符串的赋值*/#include<stdio.h>char b[20];//global variable,int main(){ char a[]="xin nian kuai le"; void copy_char(char * p); copy_char(a); return 0;}/*以字符指针类型为参数*/void copy_char(char * p){ int i;原创 2022-02-15 15:37:15 · 1050 阅读 · 0 评论 -
51单片机的温度测量和显示【仿真】
#include <REG52.H>#include <intrins.h>#define uint unsigned int#define uchar unsigned charsbit DS1302_CLK = P1^7; //实时时钟时钟线引脚 sbit DS1302_IO = P1^6; //实时时钟数据线引脚 sbit DS1302_RST = P1^5; //实时时钟复位线原创 2022-02-14 17:55:59 · 2586 阅读 · 2 评论 -
C语言指针对二维数组输入输出
C语言使用指针对成绩的录入和输入//指向数组的指针作为函数参数/*例题题目来源于谭浩强C语言编程第五版251页有一个班,有三名同学,各学四门课,计算总平均分和指定某位同学的全部成绩并且能自主判断不及格同学的各科成绩*/#include <stdio.h>int main(){ void average(float * p,int n ); void search(float(*p)[4],int n); void score_input(float sco原创 2022-02-12 17:58:11 · 4501 阅读 · 0 评论 -
自动判断某年任意日期之前的天数
#include<stdio.h>int main(){ //首先判断月份之前的天数 int day,month,year,sum,leap; printf("please input your year,month,day\n"); scanf("%d,%d,%d",&year,&month,&day);//be aware of "," switch(month) { case 1:sum=0;b.原创 2022-02-05 09:40:57 · 524 阅读 · 0 评论 -
c语言插序算法
/*判断数据大小,按从小到大顺序插入到数组里面*/#include<stdio.h>#include <stdbool.h>int a[9] = {2,3,5,9,15,19,25,29};int main(){ int pos; scanf("%d",&pos); bool fask = true; for(int i=0;i<8;i++) { if(a[i]>pos) {fask = false;原创 2022-02-02 20:50:15 · 648 阅读 · 0 评论 -
C语言排序算法
#include<stdio.h>void main(){ void sort(int a[],int n);//函数声明 int a[10],i; printf("please input your data\n"); for(i=0;i<10;i++) { scanf("%d",&a[i]); } printf("the array is :\n"); for(i=0;i<10;i++)原创 2022-02-02 20:46:23 · 234 阅读 · 0 评论 -
C语言切换字体颜色
#include<stdio.h>#include<conio.h>#include <windows.h>void textcolor(int color){ HANDLE hc=GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hc,0|color);}void main(){ int color; for(color=1;color<16;color+原创 2022-02-02 20:44:21 · 2590 阅读 · 0 评论 -
C语言求阶乘和
/*求阶乘1+2!+3!+...+N!的和*/#include"stdio.h"void main(){int add_multiply(int n);int m;printf("请你输入需要计算的阶乘项数:\n");scanf("%d",&m);add_multiply(m);}//求解阶乘和的函数int add_multiply(int n){ int i,result=1,k=0; for(i=1;i<=n;i++) {原创 2022-02-02 20:41:58 · 955 阅读 · 0 评论 -
使用指针对数组的指定输出
这里程序较短,只把程序写在一个.c文件里面/*使用指针二维数组实现输入行列实现输出对应值*/#if(1)//只是条件编译,不影响,可与后面endif一起删去#include <stdio.h>void pointer(int array_a[2][3],int m,int n);void main(){ int array_b[2][3] ; int i,j,m,n; int temper=0; printf("请你输入数组\n"); fo原创 2022-01-29 21:12:51 · 591 阅读 · 0 评论 -
codeblock实现数组倒序输出
C语言数组逆序输出原创 2022-01-28 21:43:25 · 482 阅读 · 0 评论 -
【codeblockC语言多文件程序】
``首先建立一个Print.c文件`.c文件一般为需要写的函数,类似于单片机的led.c#include "printf.h"void print (){ printf("mawei");}再把.c所写函数放入print.h文件中#ifndef PRINYF_H_INCLUDE//这里是防止重复编译#define PRINYF_H_INCLUDE//代码要全部写在中间extern void print();#endif第三步把核心东西写在main.c文件中,这样子代原创 2022-01-28 20:42:04 · 1041 阅读 · 0 评论