- 论坛徽章:
- 0
|
小弟我编了一段程序出错了,请高人指点
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct type
{char disk[100];
int percent;
}type1;
char *destney[100];
int main(int argc, char* argv[])
{
FILE *useshell;
FILE *wstream;
FILE *fp_in;
char buf[1024];
struct type *p;
p=&type1;
memset(buf,'\0', sizeof(buf));
useshell=popen("df -k | awk 'NR>1{print $1,$5+0}'","r");
craetfile=fopen("used_percent.txt","w+");
fread(buf,sizeof(char),sizeof(buf),useshell);
fwrite(buf,1,sizeof(buf),creatfile);
pclose(useshell);
fclose(creatfile);
read_in=fopen("used_percent.txt","r" );
while (!feof(read_in)){
fscanf(fp_in,"%s %d",&(type1.disk),&(type1.percent));
printf("%s %d\n",type1.disk,type1.percent);
}
{printf("请输入要监控目录的目录名:");
scanf("%s",destney);
if(strcmp(destney,(*p).disk)==0)
printf("%d",type1.percent);
else
printf("该目录不存在");
}
return 0;
} |
|
|