#include <string>
#include <iostream>
using namespace std;
int main(int argc, char *argv[], char *envp[])
{
bool numberLines = false; // Default is no line numbers.
// If /n is passed to the .exe, display numbered listing
// of environment variables.
if ((argc == 2) && _stricmp(argv[1], "/n") == 0)
numberLines = true;
// Walk through list of strings until a NULL is encountered.
for (int i = 0; envp[i] != NULL; ++i)
{
if (numberLines)
cout << i << ": "; // Prefix with numbers if /n specified
cout << envp[i] << "\n";
}
for (int i = 0; i < argc; ++i)
{
std::cout << "命令行参数: " << i << ": " << argv[i] << std::endl;
}
}
argc是参数的数量;argv是一个数组,argv[0]是程序名,argv[1]是第一个参数,......;这是标准C++的&#x