C++带参数的main函数的程序运行说版本不兼容
这是源程序:
#include <iostream.h>
void main(int argc,char *argv[])
{
cout<<"The number of command line arguments is "<<argc<<endl;
cout<<"The program name is "<<argv[0]<<endl;
if(argc>1)
{
cout<<"The command line arguments: ";
for(int i=1;i<argc;i++)
cout<<argv[i]<<endl;
}
}
可以运行了,主要是在头文件处改了,修改后的程序如下:
#include <iostream>
using namespace std;
void main(int argc,char *argv[])
{
cout<<"The number of command line arguments is "<<argc<<endl;
cout<<"The program name is "<<argv[0]<<endl;
if(argc>1)
{
cout<<"The command line arguments:
";
for(int i=1;i<argc;i++)
cout<<argv[i]<<endl;
}
}
程序的运行结果如下:
下一篇:net文件怎样修复?
上一篇:java开发工程师的工资高吗?
热门标签: