- Xóa 1 file dùng Remove
/**
* Cafedev.vn - Kênh thông tin IT hàng đầu Việt Nam
*
* @author cafedevn
* Contact: cafedevn@gmail.com
* Fanpage: https://www.facebook.com/cafedevn
* Instagram: https://instagram.com/cafedevn
* Twitter: https://twitter.com/CafedeVn
* Linkedin: https://www.linkedin.com/in/cafe-dev-407054199/
*/
#include <stdio.h>
int main()
{
remove("d:/urls1.dat");
return 0;
}
2. Xóa 1 File dùng Unlink
/**
* Cafedev.vn - Kênh thông tin IT hàng đầu Việt Nam
*
* @author cafedevn
* Contact: cafedevn@gmail.com
* Fanpage: https://www.facebook.com/cafedevn
* Instagram: https://instagram.com/cafedevn
* Twitter: https://twitter.com/CafedeVn
* Linkedin: https://www.linkedin.com/in/cafe-dev-407054199/
*/
#include <stdio.h>
int main()
{
remove("C:/pete.txt");
return 0;
}
3. Cho biết thông tin FAT
/**
* Cafedev.vn - Kênh thông tin IT hàng đầu Việt Nam
*
* @author cafedevn
* Contact: cafedevn@gmail.com
* Fanpage: https://www.facebook.com/cafedevn
* Instagram: https://instagram.com/cafedevn
* Twitter: https://twitter.com/CafedeVn
* Linkedin: https://www.linkedin.com/in/cafe-dev-407054199/
*/
#include <stdio.h>
#include <dos.h>
void main(void)
{
struct fatinfo fat;
getfatd(&fat);
printf("Sectors per cluster %d\n", fat.fi_sclus);
printf("Clusters per disk %u\n", fat.fi_nclus);
printf("Bytes per cluster %d\n", fat.fi_bysec);
printf("Disk type %x\n", fat.fi_fatid & 0xFF);
}
4. Đếm tần suất 1 kí tự trong 1 file
5. Đọc nội dung 1 file
/**
* Cafedev.vn - Kênh thông tin IT hàng đầu Việt Nam
*
* @author cafedevn
* Contact: cafedevn@gmail.com
* Fanpage: https://www.facebook.com/cafedevn
* Instagram: https://instagram.com/cafedevn
* Twitter: https://twitter.com/CafedeVn
* Linkedin: https://www.linkedin.com/in/cafe-dev-407054199/
*/
#include <stdio.h>
void main(void)
{
FILE *fp;
char ch;
fp = fopen("websites.txt","r");
ch = getc(fp);
while(ch!=EOF)
{
putchar(ch);
ch = getc(fp);
}
printf("\n\n");
}
6. Chọn ổ đĩa trong DOS
/**
* Cafedev.vn - Kênh thông tin IT hàng đầu Việt Nam
*
* @author cafedevn
* Contact: cafedevn@gmail.com
* Fanpage: https://www.facebook.com/cafedevn
* Instagram: https://instagram.com/cafedevn
* Twitter: https://twitter.com/CafedeVn
* Linkedin: https://www.linkedin.com/in/cafe-dev-407054199/
*/
#include <stdio.h>
#include <dir.h>
void main(void)
{
int drives;
drives = setdisk(3);
printf("The number of available drives is %d\n", drives);
}
8. Cho biết kích thước 1 file
/**
* Cafedev.vn - Kênh thông tin IT hàng đầu Việt Nam
*
* @author cafedevn
* Contact: cafedevn@gmail.com
* Fanpage: https://www.facebook.com/cafedevn
* Instagram: https://instagram.com/cafedevn
* Twitter: https://twitter.com/CafedeVn
* Linkedin: https://www.linkedin.com/in/cafe-dev-407054199/
*/
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
int main()
{
int fp;
long file_size;
if ((fp = open("f:/cprojects/urls.txt", O_RDONLY)) == -1)
printf("Error opening the file \n");
else
{
file_size = filelength(file_handle);
printf("The file size in bytes is %ld\n", file_size);
close(fp);
}
return 0;
}