⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1a.c

📁 liunx下的shell实现;进程、线程同步的实现;I/O系统调用的比较(mmap)——操作系统的课程设计
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#define N 1024struct buffer{char buff[N];struct buffer *next;};int main(void){void shuchu(struct buffer *q,int j);int fpin;struct buffer *head=NULL,*p;int i=1,j;fpin=open("text",O_RDONLY);if(fpin<0)	{	printf("can't open this file\n");	return 1;	}printf("%d",fpin);while(i){p=(struct buffer*)malloc(sizeof(struct buffer));if(head==NULL){p->next=NULL;head=p;}else{p->next=head;head=p;}j=i;i=read(fpin,p->buff,N);}close(fpin);shuchu(head,j);} void shuchu(struct buffer *q,int j){int fpout;int i,flag=0;char temp[N];fpout=open("text",O_WRONLY);do{for(i=N-1;i>=0;i--){temp[N-i-1]=q->buff[i];}q=q->next;if(flag==0)		{write(fpout,temp+1024-j,j);		flag=1;		}else		{		write(fpout,temp,N);		}}while(q!=NULL);close(fpout);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -