Looks like the environment variable REQUEST_METHOD never exists. You are calling the string constructor on a NULLpointer. This code will not cause a seg faut.
Code:
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream.h>
using namespace std;
int main(int argc, char *argv[])
{
int iSize;
char * pEnv;
if (( pEnv = getenv("REQUEST_METHOD" )) == NULL )
{
cout << "Env variable REQUEST_METHOD does not exist" << endl;
}
else
{
string strMethod( getenv("REQUEST_METHOD"));
cout << "String is :" << strMethod.c_str() << endl;
}
return 0;
}