您的位置:首页 > 移动开发 > 微信开发

获取ubuntu系统内存大小的小程序

2012-12-06 16:24 375 查看
#include <stdio.h>

#include <unistd.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <stdlib.h>

#include <string.h>

#include <linux/kernel.h>

static int print_memory_size(void)

{

int errorCode = 0;

struct sysinfo si;

errorCode = sysinfo(&si);

if (errorCode) {

printf("Failed to get memory type: %d \n", errorCode);

return -1;

}

printf("Total memory : %ld KB\n", (si.totalram / 1024));

return 0;

}

void main(void)

{

print_memory_size();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐