#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include<io.h>
#include<dos.h>
#define true 1
#define false 0
#define sz (sizeof(float))
char *TenTep;
//---------------------------
void CreateFile(char *TenTep);//Tao tep nhi phan chua cac so thuc
void ViewFile(char *TenTep);//Cho hien danh sach cac so thuc trong tep
int FileNodes(char *TenTep);//Tra ve so phan tu tren tep
int EoF(FILE *f);//Tra ve gia tri true neu cuoi tep, false neu chua cuoi tep
//int EoR(FILE *f);//Tra ve gia tri true neu cuoi run, false neu chua cuoi run
//---------------------------
//Tao file co n phan tu
void CreateFile(char *TenTep)
{int i,m;float x;
FILE* f;
if(f
==NULL) {printf("\nKhong the mo file!");return;} else {
printf("\nCho biet so phan tu can dua vao tep: "); printf("\nHay nhap %d so: ",m
); for(i=0;i<m;i++)
}
}
};
//---------------------------
//Hien thi noi dung file len man hinh
//====================================
void ViewFile(char *TenTep)
{float x;
char newname[8];
FILE* f;
if(f
==NULL) {printf("\nKhong the mo file!");return;} else {
printf("\nCac phan tu tren tep '%s':\n\n",TenTep
); }
};
//---------------------------
/*//Hien thi noi dung file len man hinh
/////////////////////////////////////////////////////////
void ViewRun(char *TenTep)
{float x;int i;
FILE* f;
f = fopen(TenTep,"rb");
if(f==NULL) printf("\nKhong mo duoc tep!");
else {
rewind(f);
i=1;
printf("\n\nCac run tren tep %s:\n",TenTep);
while(1)
{printf("\n%3d: ",i);
while(1)
{if(fread(&x,sz,1,f)>0) printf("%5.0f",x);
if (EoR(f)) {i++;break;}
}
if(EoF(f)) break;
} }
fclose(f);
};*/
//---------------------------
int FileNodes(char *TenTep)
{int k;float x;
FILE
*f
= fopen(TenTep
,"rb"); fseek(f
,0,2);//Ve cuoi tep return(k);
};
//---------------------------
int EoF(FILE *f)
{float x;
return(false);
};
return(true);
}
//---------------------------
//===========================================================
void DoiTen(char *tep)
{
char newname[8];
{
printf("\n Doi ten thanh cong tu '%s' sang '%s'",tep
,newname
); }
else
}
//===========================================================
//ham loai bo file
void LoaiFile(char *tep)
{
printf("\nBan dang thuc hien thao tac nguy hiem!"); else perror("Khong xoa duoc tep"); }
//===========================================================
void ChangePro(char *tep)
{
if(_chmod
(tep
,1,FA_HIDDEN
)==0) printf("\nThuoc tinh cua tep da duoc thay doi thanh tep an (Hidden)"); else perror("\nKhong the thay doi thuoc tinh"); }
//===================================================
//Ma hoa file
void Mahoa(char *TenTep)
{float x;
char newname[8];
FILE* f,f1;
if(f
==NULL) {printf("\nKhong the mo file!");return;} else {
printf("\nCac phan tu tren tep sau khi ma hoa '%s':\n\n",TenTep
); while(fread(&x
,sz
,1,f
)>0) { x=x+5;
//fwrite(&x,sz,1,f1);
}
// while(fread(&x,sz,1,f1)>0) fwrite(&x,sz,1,f);
}
//fclose(f1);
};
//===================================================
//giai ma file sau khi bi ma hoa
void Giaima(char *TenTep)
{float x;
char newname[8];
FILE* f;
if(f
==NULL) {printf("\nKhong the mo file!");return;} else {
printf("\nCac phan tu tren tep sau khi giai ma '%s':\n\n",TenTep
); while(fread(&x
,sz
,1,f
)>0) { x=x;
//fwrite(&x,sz,1,f);
}
}
};
//===================================================
void main()
{
char ch6, *tep, *ThongBao,newname[8];
int fg;
clrscr();
textmode(C80);
textcolor(YELLOW);
textbackground(BLUE);
window(1,1,80,25);
while(1)
{clrscr();
printf("\n Tap thao t*c tren File") ; printf("\nÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ"); printf("\n5. Thay doi thuoc tinh cua tep"); printf("\n6. Dem so phan tu trong tep"); printf("\nz. Tro ve MENU chinh"); printf("\n\nHay chon chuc nang 1 -> z: "); if(ch6=='Z') break;
switch(ch6)
{
case '1':
CreateFile(tep);
ThongBao="Tep da tao xong, nhan phim bat ky de tiep tuc";
getch();
break;
case '2':
ViewFile(tep);//printf("\n\nSo phan tu tren tep = %5d",FileNodes(tep));
ThongBao="Xem xong nhan phim bat ky";
getch();
break;
case '3':
DoiTen(tep);
getch(); break;
case '4':
LoaiFile(tep);
getch();break;
case '5':
ChangePro(tep);
getch();break;
case '6':
printf("\nSo phan tu tren tep:=%5d",FileNodes
(tep
)); getch();break;
case '7':
ViewFile(tep);
Mahoa(tep);
fg=1;
getch();break;
case '8':
if(fg==1) {Giaima(tep);fg=0;}
else printf("\nChua co File ma hoa") ; getch();break;
}
}
}