show code
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <string>
using namespace std;
void GetCurrentLogDirPath();
int main()
{
GetCurrentLogDirPath();
return 0;
}
void GetCurrentLogDirPath()
{
bool bResult = false;
FILE * pFile;
char buffer[10];
pFile = popen("readlink /home/benebot/log/latest", "r");
if (NULL == pFile)
{
return;
}
string strCurrLogDirPath;
while (!feof(pFile))
{
if (fgets(buffer, 10, pFile) == NULL)
break;
fputs(buffer, stdout);
strCurrLogDirPath.append(buffer);
}
cout<<"strCurrLogDirPath is %s" << strCurrLogDirPath.c_str() <<endl;
if(NULL != pFile)
{
pclose(pFile);
pFile = NULL;
}
return;
}