自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 收藏
  • 关注

原创 C语言中__FUNCTION__,_FILE_,_LINE_用法

运行结果:

2022-04-14 11:54:14 827

原创 git忽略指定文件方式

命令:git config core.excludesfile ~/gitignore.txt[root@11:17:02]$ cat ~/gitignore.txt*.o*.so*.a*.cmd*.svn*.git

2022-04-13 11:52:09 4266

原创 前端获取时区

new Date‘UTC+’ + (0 - new Date().getTimezoneOffset() / 60);Intl.DateTimeFormat().resolvedOptions().timeZone

2022-04-13 11:43:58 1831

原创 DHCP租约过期与更新

DHCP的租约到期之前,如果设备(电脑、路由器)正在工作的话,是会自动续约的,不会造成网络中断。如果电脑在租约到期之后重新开机,会得到一个新的IP地址,过程是自动的,不需要用户干涉。 再次申请的话,IP地址有可能或获取到上次使用的IP ,因为DHCP虽然 看上去是随机分配IP地址,但是如果客户端第一次有向DHCP服务器获取IP地址话,这个时候DHCP服务器会把这台客户端的 mac和IP 记录下路,如果下次再申请,而这个IP 地址又没有被分出去的话,那么会...

2020-12-13 20:37:40 15361

原创 samba共享文件夹在Windows下无修改权限

命令格式:    chown [选项]… [所有者][:[组]] 文件…执行:sudo chown -hR xxx:root share/chmod -R go+rwx share/(xxx为Linux用户名,share为共享目录,或者目录下文件)

2020-12-08 19:48:50 1845

原创 字符串按单词逆序(how are you__you are how)

#include <stdio.h>#include <stdlib.h>#include <string.h>void reverseString(char *begin,char *end){ for(;begin < end;begin++,end--) { char t = *begin; *begin = *end; *end = t; }}void reverseWord(char *s,size_t len){ c

2020-09-19 19:12:56 660

原创 不使用库函数将字符串(不同进制)转为整型数字

输入:16进制格式:前缀有0x,例如0x1f10进制格式:无前缀,例如123452进制格式:前缀有0,例如010010不需要考虑正负数输出:返回整型数字#include <stdio.h>#include <string.h>#include <stdlib.h>int StrToInt(char *Convert){ int i = 0; int sum = 0; if('0' == *Convert && ('x' == *

2020-09-17 22:25:47 492

原创 Linux下线程的同步(信号量), 用多线程程序设计一个火车票售票系统,要求至少有两个售票 ,每个售票窗口 不能重复卖票,将100张车票均匀的从两个 窗口卖出即可。

#include <stdio.h>#include <stdlib.h>#include <pthread.h>#include <semaphore.h>int mem[2]={0};sem_t sem_mem;int count = 1;int my_malloc(){ int i = 0 ; sem_wait(&sem_mem); for(i = 0 ;i < 2;i++) { if(0 == mem[i]

2020-08-15 19:17:26 1599

原创 Linux(C语言):关于线程中互斥锁的示例,模拟银行窗口

假设银行三个窗口,十个人办业务#include <stdio.h>#include <unistd.h>#include <pthread.h>int COUNT = 3 ;//窗口数pthread_mutex_t mutex;void* th(void* arg){ while(1) { pthread_mutex_lock(&mutex); if(COUNT>0) { COUNT--; pthread_mute

2020-08-15 16:03:00 180

原创 Linux(C语言):关于线程的创建(参数传递)、回收的示例

参数为结构体将信息传递给子线程,子线程修改信息后(在buf后加个时间)传递给主线程#include <stdio.h>#include <pthread.h>#include <string.h>#include <stdlib.h>#include <time.h>#include <strings.h>typedef struct{ int num; char buf[256];}INFO;void *

2020-08-14 23:33:15 1163

原创 数据结构(C语言):二叉树的创建、遍历、销毁等操作

tree.h#ifndef _TREE_H_#define _TREE_H_#include <stdio.h>#include <stdlib.h>typedef struct node{ char data; struct node *pL; struct node *pR;}BTNode;extern BTNode *createBinTree();extern void preOrder(BTNode *pRoot);extern void

2020-08-10 21:57:18 522

原创 数据结构(C语言):顺序队列的创建、入队、出队、销毁等操作

seqQueue.h#ifndef _SEQ_QUEUE_H_#define _SEQ_QUEUE_H_#include <stdio.h>#include <stdlib.h>typedef int DataType;typedef struct list{ DataType *pBase; int front; int rear;}SeqQueue;#define SEQ_QUEUE_MAX_SIZE 10extern SeqQueue *

2020-08-10 21:44:06 2595

原创 数据结构(C语言):链式队列的创建、入队、出队、销毁等操作

queue.h#ifndef _QUEUE_H_#define _QUEUE_H_#include <stdio.h>#include <stdlib.h>typedef int DataType;typedef struct node{ DataType data; struct node *pNext;}QueueNode;typedef struct list{ QueueNode *pFront; QueueNode *pRear; in

2020-08-10 21:32:40 1441

原创 数据结构(C语言):栈的创建、入栈、出栈、栈的销毁等操作

stack.h#ifndef _STACH_H_#define _STACH_H_#include <stdio.h>#include <stdlib.h>typedef int DataType;typedef struct node{ DataType data; struct node *pNext;}StackNode;typedef struct list{ StackNode *pTop;//栈顶 int cLen;}StackLis

2020-08-10 21:27:25 502

原创 数据结构(C语言):双向链表的创建、插入、修改、删除、查找、修改等操作

.h文件#ifndef DOUBLELINK_H_#define DOUBLELINK_H_#include <stdio.h>#include <stdlib.h>#include <string.h>/*数据域数据类型*/typedef struct student{ int id; char name[32]; int score;}DataType;/*结点数据类型*/typedef struct node{ DataType

2020-08-10 21:21:10 1684

原创 数据结构(C语言):单链表的创建、插入、修改、删除、查找、修改等操作

.h头文件#ifndef _LINK_H_#define _LINK_H_#include <stdio.h>#include <stdlib.h>/*数据域数据类型*/typedef int DateType;/*结点数据类型*/typedef struct node{ DateType data;//数据域 struct node *pNext;//指针域}LinkNode;//标签数据类型typedef struct list{ Lin

2020-08-07 21:31:13 3539

原创 Linux学习笔记(C语言):用无名管道实现英文词典的查询

要求输入单词,输出单词的详细解释(进程间通信)#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#define MAX 19661//字典行数,一行一个词int main(int ar

2020-07-30 23:22:19 274

原创 C语言统计字符串中某指定字符串出现的次数

这里为封装函数int sumStr(char*s1, char* s2)//统字符串s2在字符串s1中出现的次数{ int i = 0; char* p = s1; while ((p = strstr(p, s2)) != NULL) { i++; p += strlen(s2); } return i;}

2020-07-28 20:08:21 7094

原创 Linux学习笔记(C语言):tcp实现客户端与服务器端聊天

客户端#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h> /* See NOTES */#include <sys/socket.h>#include <time.h>#include <sys/socket.h>#include &l

2020-07-25 20:10:20 403

原创 Linux学习笔记(c):TCP客户端向服务器端传输照片

客户端#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h> /* See NOTES */#include <sys/socket.h>#include <time.h>#include <sys/socket.h>#include ..

2020-07-25 19:15:36 1300

原创 Linux学习笔记:共享内存传输照片实现照片复制

写端:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>int main(int argc, const char *argv[]){ key_t key = ftok("/home/linux",'!');//创建临时键值 i..

2020-07-24 22:55:53 626

原创 标准IO、文件IO实现文件、照片的复制

1.fgetc/fputc#include <stdio.h>#include <errno.h>int main(int argc, const char *argv[]){ FILE * src; FILE * dest; src = fopen("/home/linux/11.jpg","r"); dest = fopen("./1.jpg","w"); if(NULL == src || NULL == dest) { perror("fopen e

2020-07-24 21:50:12 848

原创 Linux学习笔记(c):udp客户端向服务器端传输照片

客户端#include <stdio.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <sys/types.h> #include <sys/socket.h>#include <netinet/in.h>#include <netinet/ip.h>#include <time.h&g.

2020-07-24 21:09:26 503

原创 字符串函数笔记,指针传参封装字符串函数,strcmp,strcpy等。

size_t Strlen(const char * s)//统计有效长度{ if('\0' == *s) { return 0; } else { return Strlen(s+1) + 1; }}char *Strcpy(char *dest,const char *src)//字符串复制{ char *ret = dest; while(*src) { *dest++ =

2020-07-23 21:23:54 197

原创 C语言实现电话本存储到本地文件

Linux下(只做了增加和查找功能)#include <stdio.h>#include <string.h>struct info{ char name[256]; char addr[256]; char phone[15];};int add()//增加信息{ struct info person; FILE * fp = fopen("phoneBook.txt","a+"); if(NULL == fp) { printf("fopen

2020-07-12 21:25:32 369 1

原创 如何用最短的代码实现用户任意输入并打印输出(C语言)。

#include <stdio.h>int main(void){ while(1) { fputc(fgetc(stdin),stdout); } return 0;}

2020-07-09 22:01:23 298

原创 统计文本文件中a-z,出现的次数。(Linux C语言)

#include <stdio.h>int main(int argc, const char *argv[]){ FILE * fp; fp = fopen("/etc/passwd","r"); if(NULL == fp) { printf("file open error\n"); return 1; } int i; char a[26] = {97}; for(i = 0;i < 26;++i) { a[i] = 97 + i; } i

2020-07-09 21:05:52 737

原创 C语言简单的编写实现2048小游戏

(这里只是初步大致的写出来了主要内容,很多地方还没有完善。比如:没有做玩到2048时的判断结束画面,以及判断失败的条件)#include <stdio.h>#include <termios.h>#include <unistd.h>#include <time.h>void startScreen()//开始界面{ int i; int j; char _2048[][128]={ {"▬ ▬ ▬ ▬ ▬ ▬▬▬

2020-07-08 21:02:33 1137

原创 C语言实现字符串12345转为整型12345

(这里封装了一个函数)#include <stdio.h>#include <string.h>int change(char *s,size_t n){ int i; int sum = 0; for(i = 0;i < n;++i) { sum = sum * 10 + *(s + i) - 48;//字符0对应十进制的ASCII码为48 } return sum;} int main(void){ char s[] = "12345";

2020-07-07 20:03:44 1786

原创 C语言简单实现求二维数组的鞍点

鞍点:该行最大值,同时为列最小值(这里为3*4矩阵)#include <stdio.h># define N 3# define M 4 int main(void){ int a[N][M]; int i,j; int flag = 0;//判断标志 printf("输入矩阵:\n"); for(i = 0;i < N;++i) { for(j = 0;j < M;++j) { scanf("%d",&a[i][j]); }

2020-07-07 19:37:27 2938

原创 C语言实现简单的打印杨辉三角

思路:1.杨辉三角各行第一个数都是 1。2.从第三行开始,各行除指出的第一个数和最后一个外,其余各数都是上一行同列和前一列两数之和。即:a[i][j] = a[i - 1][j - 1] + a[i - 1][j];(这里打印前十行)#include <stdio.h>#define N 11int main(void){ int i,j,a[N][N]; for(i = 1;i < N;++i) { a[i][1] = 1; a[i][i] = 1

2020-07-07 16:49:36 381

原创 c语言实现对日历的输出

要求:输入年份和月份,输出该月的日历只输入年份时,输出该年全部月历(这里输入以分号结束)(以1900年1月1日为起始基准)#include <stdio.h>int isLeepYear(int year)//判断闰年{ return 0 == year % 4 && 0 != year % 100 || 0 == year % 400;}int daysOfMonth(int year,int month)//判断单月份天数{ int day[] = {

2020-07-03 20:47:24 4841 1

原创 C语言实现单链表对结点的删除以及插入,均在头和尾操作

#include <stdio.h>#include <stdlib.h>struct Node{ int data; struct Node *next;};void printList(struct Node *pHead)//打印链表{ struct Node *p = pHead->next; while(p) { printf("%d\n",p->data); p = p->next; }}int isEmpty(

2020-07-03 20:27:08 462

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除