一 格式
run arg1 arg2
二 传参数给程序并运行程序
1 源代码
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int i;
if(argc==3)
{
cout<<"argc="<<argc<<endl;
for(i=0;i<argc;i++)
{
cout<<"argv["<<i<<"]="<<argv[i]<<endl;
}
}
else
{
cout<<"wrong argv";
}
return 0;
}
2 编译
[root@localhost test]# g++ test2.cpp -g -o test2
3 用gdb加载test2,并运行
[root@localhost test]# gdb test2
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-100.el7_4.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http