You can consider using popen(), and then parse the results. Or under Linux, you can examine /proc/version and/or perhaps /proc/cpuinfo, to get information. Or just use "uname -a". I'm not sure if Solaris uses a similar /proc to that of Linux.
Here's a simple program:
Code:
#include <cstdio>
#include <iostream>
#include <string>
#include <fstream>
int main()
{
// here, executing a command to get results via a pipe
//
FILE* fp = popen("cat /proc/cpuinfo", "r");
if (fp)
{
char buf[1024] = {0};
while (fgets(buf, sizeof(buf), fp))
{
std::cout << buf;
}
pclose(fp);
}
// here, just reading a file the ol' fashioned way
//
std::fstream file("/proc/version", std::ios::in);
if (file)
{
std::string line;
while (getline(file, line))
{
std::cout << line << std::endl;
}
}
}