c++检测自身文件名并保存到string变量的实现

网上找的都是直接输出
没法保存到变量
希望能读取自身文件名并保存到string变量
求源码


#include <iostream>
#include <string>
using namespace std;

int main(int argc,char ** argv)  //argv[0]中保存的是程序本身的路径。
{
    string s1(argv[0]),s2;
    int n;

    n=s1.find_last_of('\\')+1;

    s2 = s1.substr(n);
    cout << s1 << endl << s2 << endl;

    system("pause");
    return 0;
}