- 博客(15)
- 收藏
- 关注
原创 process+IPC
今天学习了进程,包括fork,vfork,wait,system,exec,getpid函数vLinux中的进程包含3个段,分别为“数据段”、“代码段”和“堆栈段”。fork和vfork区别1. fork():子进程拷贝父进程的数据段,代码段. vfork():子进程与父进程共享数据段.2. fork():父子进程的执行次序不确定.vfork():保证子进程先运行,在调用exe...
2019-01-13 21:41:25 219 1
原创 系统编程
本日任务完成情况:今天学习了creat,open,read,write函数用用法和参数 还有fopen,fread,fwrite函数的用法。 要注意,open函数不同参数的区别不同 O_RDONLY 以只读方式打开 / O_WRONLY 以只写方式打开 /O_RDWR 以可读可写方式打开 O_CREAT 如果文件不存在则创建该文件 O_EX...
2019-01-12 21:09:29 844
原创 冒泡排序
#include <stdio.h>// 冒泡排序:递归void sort(int *a, int len){ if (len <= 1) return; int j; int temp; for (j = 0; j < len-1; j++) { if (a[j] > a[j+1])...
2018-08-05 20:37:18 216
原创 C语言文件复制程序
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <string.h>int main(){ char name[100]; pri...
2018-07-24 20:11:16 856
原创 双向链表的头插法
#include <stdio.h>#include<stdlib.h>typedef struct dnode{ int id; struct dnode *next; struct dnode *prior;}dnode;typedef struct dnode *Linklist;int main(int argc, char **argv){ ...
2018-06-13 20:24:18 723
原创 用指针的方法实现一个3*3矩阵的转置
#include <stdio.h>void mat(int (*p)[3],int (*q)[3]){ int i,j; for(i=0;i<3;i++) for(j=0;j<3;j++) *(*(q+j)+i)=*(*(p+i)+j);}int main(int argc, char **argv){ int a[3][3]={1,2...
2018-06-08 23:52:21 13738 2
原创 结构体的简单运用
#include <stdio.h>typedef struct student { int a; char b[10];}stu;int main(){ stu stu1; stu1.a=99; int i; for(i=0;i<10;i++) { stu1.b[i]='a'; } puts(stu1.b); ...
2018-06-03 18:13:38 202
原创 用指针将月份转换成英文
#include <stdio.h>int main(int argc, char **argv){ char *sm[12]={"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov"
2018-06-03 18:11:19 570
原创 用指针的方法,将一个数组中的数从小到大排序
#include<stdio.h>int main(){ int i,j,t,n; printf("please input n:"); scanf("%d",&n); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); printf("\n"); }
2018-05-23 23:38:27 12594
原创 有一篇文章,共有三行文字,每行八十个字符。要求分别统计出其中英文大写字母,小写字母,数字,空格,及其他字符的个数。
#include<stdio.h>int main(){ char c[3][80]; int i,j,A=0,a=0,num=0,kg=0,zf=0; printf("please input 1\n"); gets(c[0]); puts(c[0]); printf("please input 2\n"); gets(c[1]); p...
2018-05-18 22:39:03 8241 1
原创 找出一个二维数组中的鞍点,即该位置上的元素在该行上最大,在该列上最小,也可能没有鞍点。
#include<stdio.h>int main(){ int a[5][5]; int i,j,max,min,c,d,b=0; for(i=0;i<5;i++) { for(j=0;j<5;j++) { printf("please input a[%d][%d]",i,j); ...
2018-05-18 22:35:01 2223
原创 将两个字符连接起来,不能使用strcat函数
#include<stdio.h>int strcat(char c[100],char d[100]){ int i,j; puts(c); puts(d); for(i=0;c[i]!='\0';i++); for(j=0;d[j]!='\0';j++) { c[i++]=d[j]; } c[i]='\0'; ...
2018-05-13 20:16:41 11335
原创 输出给定二位数组每一行的最大值,和数组的最小值
#include <stdio.h>#include <stdlib.h>int main(){ int i,j,a,b,min,max; int a[3][4]={7,6,8,25,22,75,33,41,4,0,11,23}; for (i=0;i<3;i++) { max=a[i][0]; for (j=1;j<4;j++) { if(max&l...
2018-05-13 20:04:47 770
原创 输入一行字符,分别统计出英文字母,空格,数字,和其它字符的个数.
#include <stdio.h>#include <stdlib.h>int main(){ int a=0,b=0,c=0,d=0,ch; while((ch=getchar())!='\n') { if(ch>='0'&&ch<='9') a++; else if((ch>='a' && ch<='z'...
2018-05-11 20:43:52 5128
原创 打印菱形“*”星号组合
#include<stdio.h>int main(){ int i,j,n; for(i=0;i<4;i++) { for(n=0;n<4-1-i;n++) { printf(“ ”); } for(j=0;j<2*i+1;j++) { ...
2018-05-08 21:12:49 1383
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人