当前位置: 技术问答>linux和unix
请问如何用C编写读取硬盘分区表信息的程序?
来源: 互联网 发布时间:2015-02-08
本文导语: 谢谢 | 给分就行 #include #include int main() { FILE *sda,*f; sda=NULL; f=NULL; //你可以读写任意数目的byte,一般是512,一个引导扇 long total=1024*64; long pointer=0; //初始化缓冲区 char buf...
谢谢
|
给分就行
#include
#include
int main()
{
FILE *sda,*f;
sda=NULL;
f=NULL;
//你可以读写任意数目的byte,一般是512,一个引导扇
long total=1024*64;
long pointer=0;
//初始化缓冲区
char buff[256];
memset(buff,0,256);
if(NULL==(sda=fopen("/dev/ hda","rb")))
{
printf("cant open the sda filen");
return 1;
}
if(NULL==(f=fopen("/home/mysda.dat","wb")))
{
printf("can't open the mysda.dat filen");
fclose(f);
return 1;
}
printf("now,both file were openedn");
printf("the FILE pointer is %d and %dn",sda,f);
while(pointer
#include
#include
int main()
{
FILE *sda,*f;
sda=NULL;
f=NULL;
//你可以读写任意数目的byte,一般是512,一个引导扇
long total=1024*64;
long pointer=0;
//初始化缓冲区
char buff[256];
memset(buff,0,256);
if(NULL==(sda=fopen("/dev/ hda","rb")))
{
printf("cant open the sda filen");
return 1;
}
if(NULL==(f=fopen("/home/mysda.dat","wb")))
{
printf("can't open the mysda.dat filen");
fclose(f);
return 1;
}
printf("now,both file were openedn");
printf("the FILE pointer is %d and %dn",sda,f);
while(pointer