【main()的参数探究】
2024-10-07 23:04:56
恩...今天研究信安的课件的时候看到一段对于main(int argc,char *argv[])的编程
所以探究探究main()函数的参数
探究程序如下:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#define oo 0x13131313
using namespace std;
int main(int n, char *s[ ])
{
printf("%d\n",n);
for(int i=0;i<=n;i++)
printf("%s\n",s[i]);
return 0;
}
一.输入参数的方法:
打开cmd进入当前目录下
C:\Users\Administrator\Desktop>
输入
1.exe aa aa aa
这4个均为main 的参数
二.参数的存储
n=4
s[0] 1.exe
s[1] aa
s[2] aa
s[3] aa
三.输出结果
四.应用
实际上cmd的控制命令(dir,cd之类)也是这样类似的cpp(类c)程序?
所以才能控制参数
2015 5/11
最新文章
- 创建SSH Key连接github或gitlab
- C#EasyHook例子C# Hook 指定进程C#注入指定进程 z
- 那传说中的P、NP以及NPC问题
- Apache JMeter - load test tool
- nodeJS起步 1
- linux 高精度定时器例子
- Spring Boot启动过程(二)
- JavaScript高级程序设计(二)
- spring boot+mybatis+quartz项目的搭建完整版
- (八)shell工具-重点
- ASP.NET MVC 学习笔记-7.自定义配置信息(后续)
- 软件扒网站? 爬虫? F12查看源码? 查看网页源代码?浏览器sources? 区别和联系!
- 【转】 ISP-镜头阴影校正(LSC)
- fges
- css:清楚html所有标签自带属性
- scope 前缀开头的方法
- html 塊 div span
- 为什么使用DLL
- 一个登陆浏览api接口; 其他相关: Form_with参数的不同写法; 简单使用curl。
- Nlog- Application Logging in C#