Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Free disk Space on the drive

    I want to find out free disk space on my system within a C/C++ program.
    When i am running this code :

    #include <stdio.h>
    #include <sys/vfs.h>

    int main()
    char path[300];
    struct statfs *buff;
    int i;

    i = statfs(path, buff);
    if (i==0)
    printf("%s \t %s\n", *buff.f_bfree, *buff.f_bavail);
    printf("%s \t %d\n)", "Error occured",i);

    And the result i am getting is:

    error -1

    that means there is some problem with the execution of statfs function.

    Can any body help me out what the problem is??


  2. #2
    struct statfs sf;

    i = statfs("/path", &sf);

    Also, fields of statfs struct are not strings, so must not be output with %s.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts