指针控制的多返回值函数如何调用?如何使用返回值?
愿得一人心 2011-04-29 11:15:03 [code=C/C++][/code
//获取磁盘总空间和剩余空间
int getDiskSize(unsigned int *blksize,unsiged int *blkfree)
{
FILE *fp = fopen("/etc/mtab","rb");
if(NULL == fp)
{
return 0;
}
while(1)
{
struct mntent *mt = getmntent(fp);
if(NULL == mt)
{
break;
}
if(NULL != strstr(mt->mnt_fsname,"/dev/sd") || NULL != strstr(mt->mnt_fsname,"/dev/hd"))
{
struct statfs buf;
statfs(mt->mnt_dir,&buf);
*blksize += (buf.f_bsize/1024*buf.f_blocks);
*blkfree += (buf.f_bsize/1024*buf.f_bfree);
}
}
fclose(fp);
return 0;
}
我现在想调用这个函数,获得磁盘总空间和剩余空间,该怎么调用呀?参数,返回值该怎么处理呢?
小妹没接触过多返回值的情况,不敢下手了,望高人指点!帮写下代码或者之前有例子贴下也行呀~