Memory Information
In Linux, system information is stored in the /proc directory of the system. Obtain the memory information from the files in the /proc directory in C and C++.
Example:
void getMemoryInfo()
{
FILE *fp = fopen("/proc/meminfo", "r");
if(NULL == fp)
printf("failed to open meminfo\n");
char szTest[1000] = {0};
while(!feof(fp))
{
memset(szTest, 0, sizeof(szTest));
fgets(szTest, sizeof(szTest) - 1, fp);
printf("%s", szTest);
}
fclose(fp);
}
Parent topic: C/C++