View Single Post
  #7   (View Single Post)  
Old 11th January 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

The following, from your original post.. should work.

Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>

int
main()
{
        size_t size;
        int buf;
        size = sizeof buf;

        sysctlbyname("hw.acpi.battery.life", &buf, &size, NULL, 0);

        printf("%d\n", buf);
        return 0;
}
Take care pal.

EDIT: Fixed the above code, should work now.

Last edited by BSDfan666; 11th January 2009 at 11:11 PM.
Reply With Quote