#include "stdafx.h"
#include <windows.h>
#include <string>
#include <iostream>
using namespace std;;

int _tmain(int argc, _TCHAR* argv[])
{

	wchar_t pBuf[MAX_PATH]; 
	GetModuleFileName(NULL, pBuf, MAX_PATH);
	char ch[MAX_PATH];
	// convert wchar_t to char
    WideCharToMultiByte(CP_ACP, 0, pBuf, -1, ch, MAX_PATH, NULL, NULL);   
	// use char to create new string
    string strPathRaw(ch);
	// find the last slash from the end of string
    string::size_type pos = strPathRaw.find_last_of( "\\/" );
	// trim the file name
	string strPathNoFilename = strPathRaw.substr( 0, pos);
	// replace single slash with double slash
	for (int i = 0; i < strPathNoFilename.length(); ++i) 
	{
		if (strPathNoFilename[i] == '\\')
		{
			strPathNoFilename.insert(i, 1, '\\');
			++i; // Skip inserted char
		}
	}
	// add 2 more slash at the end of string
	string strPathFinal = strPathNoFilename.insert(strPathNoFilename.length(), 2, '\\\\');
	cout << strPathFinal;

	return 0;
}