C with classes
This commit is contained in:
44
C/BasicSyntax/fileiostream/file_test1.cpp
Normal file
44
C/BasicSyntax/fileiostream/file_test1.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
//f means file
|
||||
int main(){
|
||||
FILE * fp, *fout;
|
||||
fp = fopen("test.dat","rb");
|
||||
if(fp == NULL){
|
||||
printf("Damn!");
|
||||
exit(0);
|
||||
}
|
||||
char arr[100];
|
||||
int i=0;
|
||||
while(fgetc(fp)!=EOF){
|
||||
fseek(fp, -1, SEEK_CUR);
|
||||
arr[i] = fgetc(fp);
|
||||
i++;
|
||||
}
|
||||
arr[i] = '\0';
|
||||
//printf("%s",arr);
|
||||
/*
|
||||
for(int i = 0; i < strlen(arr) ; i++ ){
|
||||
scanf
|
||||
}*/
|
||||
// fput();
|
||||
fout = fopen("fout.dat","ab");
|
||||
for(int i = 0; i < strlen(arr) ; i++){
|
||||
fputc(arr[i], fout);
|
||||
}
|
||||
FILE *f1;
|
||||
f1 = fopen("fout.dat","rb");
|
||||
while(fgetc(f1)!=EOF){
|
||||
//putchar(arr[i]);
|
||||
fseek(f1,-1,1);
|
||||
putchar(fgetc(f1));
|
||||
Sleep(50);
|
||||
}
|
||||
|
||||
fclose(fout);
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
1
C/BasicSyntax/fileiostream/fout.dat
Normal file
1
C/BasicSyntax/fileiostream/fout.dat
Normal file
@@ -0,0 +1 @@
|
||||
Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!
|
||||
1
C/BasicSyntax/fileiostream/test.dat
Normal file
1
C/BasicSyntax/fileiostream/test.dat
Normal file
@@ -0,0 +1 @@
|
||||
Hello,World!
|
||||
Reference in New Issue
Block a user