1:系统调用
#include
#include
#include
#include
#include#define BUFFER_SIZE 100
char * str_a = "C:\\Users\\jiang000\\CLionProjects\\systemCall\\a";
char * str_b = "C:\\Users\\jiang000\\CLionProjects\\systemCall\\b";int main(){int a_fd = open(str_a,O_RDONLY);printf("%d",a_fd);long size = lseek(a_fd,0,SEEK_END);long half_size = size / 2;long res = lseek(a_fd,-half_size,SEEK_END);int b_fd = open(str_b,O_WRONLY);printf("%d",b_fd);printf("woshi: %d",stdin);char buffer[BUFFER_SIZE];int read_cnt;while((read_cnt = read(a_fd,buffer,BUFFER_SIZE)) > 0){write(b_fd,buffer,read_cnt);}printf("bei bei");close(a_fd);close(b_fd);
}
2:库函数
#includevoid showdiff(char *file1,char * file2, char *file3);
int main(){printf("hello beibei\n");showdiff("C:\\Users\\jiang000\\CLionProjects\\helloWorld\\1.txt","C:\\Users\\jiang000\\CLionProjects\\helloWorld\\2.txt","C:\\Users\\jiang000\\CLionProjects\\helloWorld\\3.txt");
printf("hello ");
}void showdiff(char *file1,char * file2, char *file3){FILE * fp1 = 0, *fp2 = 0, * fp3 = 0;char ch1,ch2;fp1 = fopen(file1,"r");fp2 = fopen(file2,"r");fp3 = fopen(file3,"w");while(1){ch1 = (char) fgetc(fp1);ch2 = (char) fgetc(fp2);if(feof(fp1) or feof(fp2)){break;}if(ch1 == ch2){printf("%c \n",ch1);fputc(ch1,fp3);}}fclose(fp1);fclose(fp2);fclose(fp3);
}
3:相关知识
- #define stdin (__acrt_iob_func(0))
- #define stdout (__acrt_iob_func(1))
- #define stderr (__acrt_iob_func(2))
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!