Skip to content

Instantly share code, notes, and snippets.

@rajabishek
Last active August 29, 2015 14:14
Show Gist options
  • Save rajabishek/313a5e949f98ef76bf97 to your computer and use it in GitHub Desktop.
Save rajabishek/313a5e949f98ef76bf97 to your computer and use it in GitHub Desktop.
CPU & Memory information - Linux mint
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class FileHandling{
public:
void read(string name){
string line;
ifstream myfile(name.c_str());
if(myfile.is_open()){
while(getline(myfile,line))
cout << line << '\n';
myfile.close();
}
else
cout << "Unable to open file"<<endl;
}
};
int main () {
FileHandling* file = new FileHandling();
cout<<"------------------ CPU INFO ------------------------"<<endl<<endl;
file->read("/proc/cpuinfo");
cout<<"------------------------------------------------------"<<endl<<endl;
cout<<"------------------ MEMORY INFO ----------------------"<<endl<<endl;
file->read("/proc/meminfo");
cout<<"-----------------------------------------------------"<<endl<<endl;
delete file;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment