1b.c
来自「liunx下的shell实现;进程、线程同步的实现;I/O系统调用的比较(mma」· C语言 代码 · 共 63 行
C
63 行
#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 1024struct buffer{char buff[N];struct buffer *next;};int main(void){void shuchu(struct buffer *q,int j);FILE *fpin;struct buffer *head=NULL,*p;int i=1,j;fpin=fopen("text","rb");if(fpin==NULL){printf("can't open this file\n");return 1;}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=fread(p->buff,sizeof(char),N,fpin);}fclose(fpin);shuchu(head,j);} void shuchu(struct buffer *q,int j){FILE *fpout;int i,flag=0;char temp[N];fpout=fopen("text","wb");do{for(i=N-1;i>=0;i--){temp[N-i-1]=q->buff[i];}q=q->next;if(flag==0){fwrite(temp+1024-j,sizeof(char),j,fpout);flag=1;}else{fwrite(temp,sizeof(char),N,fpout);}}while(q!=NULL);fclose(fpout);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?