If you run this from a console app you can use _popen() which is pretty simple:
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
void main(void)
{
char buffer[128];
FILE *chkdsk;
if(!(chkdsk = _popen("dir c:\\*.* /on /p", "rt"

)) return;
ofstream ofs("C:\\testpipe.txt"

;
while(!feof(chkdsk)) if(fgets(buffer,128,chkdsk)) ofs << buffer;
ofs << "\nProcess returned " << _pclose(chkdsk);
}
otherwise it's a bit more complex:
#include <windows.h>
#include <string>
#include <iostream>
using namespace std;
string ExecCmd(char* cmdline)
{
PROCESS_INFORMATION proc;
int ret;
STARTUPINFO start;
SECURITY_ATTRIBUTES sa;
HANDLE hReadPipe;
HANDLE hWritePipe;
unsigned long bytesread;
char mybuff[2048];
ZeroMemory(&sa,sizeof(sa));
sa.nLength = sizeof(sa);
sa.bInheritHandle = 1;
sa.lpSecurityDescriptor = NULL;
ret = CreatePipe(&hReadPipe, &hWritePipe, &sa, 0);
if (!ret) return "CreatePipe failed";
ZeroMemory(&start,sizeof(start));
start.cb = sizeof(start);
start.dwFlags = STARTF_USESTDHANDLES;
start.hStdOutput = hWritePipe;
start.hStdError = hWritePipe;
ret = CreateProcess(0, cmdline, &sa, &sa, 1, NORMAL_PRIORITY_CLASS, 0, 0, &start, &proc);
if (!ret) return "CreateProcess failed";
WaitForSingleObject(proc.hProcess,INFINITE);
ret = ReadFile(hReadPipe, mybuff, 2048, &bytesread, NULL);
mybuff[bytesread] = 0;
if (!ret) return "ReadFile failed";
ret = CloseHandle(proc.hProcess);
ret = CloseHandle(proc.hThread);
ret = CloseHandle(hReadPipe);
ret = CloseHandle(hWritePipe);
return mybuff;
}
int main(int argc, char* argv[])
{
cout << ExecCmd("arp.exe -a"

.c_str() << endl;
return 0;
}

Hope that this helped! ;-)