Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdlib.h"
- #include "stdio.h"
- #include "string.h"
- #include "sys/types.h"
- #include "sys/sysinfo.h"
- int main()
- {
- char quit = '1';
- FILE* file;
- unsigned long physMemUsed = 0;
- char lose[200];
- char mem_str[200];
- while (quit != '0') {
- file = fopen("/proc/meminfo", "r");
- fgets(lose, 200, file);
- fgets(lose, 200, file);
- fscanf(file, "%s", mem_str);
- fclose(file);
- int i = 15;
- while (mem_str[i] != 'k') {
- if (mem_str[i] <= '9'|| mem_str[i] >= '0' ){
- physMemUsed = physMemUsed * 10 + atoi(&mem_str[i]);
- }
- ++i;
- }
- physMemUsed = physMemUsed / 1024;
- printf("%lu", physMemUsed);
- printf("\n");
- quit = getchar();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement