//命令行参数使用。
来源:互联网 发布:cf占卜抽奖软件 编辑:程序博客网 时间:2024/06/11 14:01
//命令行参数使用。
//将ComandLineArg.exe拷贝到C盘,
//cd c:\
//ComandLineArg 10 20 max // 正确用法
//ComandLineArg x // 参数不够,提示usage
//ComandLineArg 10 20 x // 参数x 不正确。
//ComandLineArg 10 20 max min // 参数多余,min不理会。
// 函数库stdlib中已经定义了,无需再定义 : 若重新定义后,提示 type error.
/*
int max( int x, int y)
{
return (x>y? x:y);
}
int min( int x, int y)
{
return (x<=y? x:y);
}
*/
/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(int argc, char * argv[])
{
int a,b;
char *operate_flag;
if (argc<4)
{
printf("Usage: ComandLineArg integer1 integer2 operate_flag \n");
exit(0);
}
a=atoi(argv[1]);
b=atoi(argv[2]);
operate_flag=argv[3];
if(0==strcmp(operate_flag, "max"))
printf("The %s of %s and %s is : %d\n",argv[3],argv[1],argv[2],max(a,b));
else if(0==strcmp(operate_flag, "min"))
printf("The %s of %s and %s is : %d\n",argv[3],argv[1],argv[2],min(a,b));
else
printf("operate_flag should be max or min !");
}
*/
//将ComandLineArg.exe拷贝到C盘,
//cd c:\
//ComandLineArg 10 20 max // 正确用法
//ComandLineArg x // 参数不够,提示usage
//ComandLineArg 10 20 x // 参数x 不正确。
//ComandLineArg 10 20 max min // 参数多余,min不理会。
// 函数库stdlib中已经定义了,无需再定义 : 若重新定义后,提示 type error.
/*
int max( int x, int y)
{
return (x>y? x:y);
}
int min( int x, int y)
{
return (x<=y? x:y);
}
*/
/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(int argc, char * argv[])
{
int a,b;
char *operate_flag;
if (argc<4)
{
printf("Usage: ComandLineArg integer1 integer2 operate_flag \n");
exit(0);
}
a=atoi(argv[1]);
b=atoi(argv[2]);
operate_flag=argv[3];
if(0==strcmp(operate_flag, "max"))
printf("The %s of %s and %s is : %d\n",argv[3],argv[1],argv[2],max(a,b));
else if(0==strcmp(operate_flag, "min"))
printf("The %s of %s and %s is : %d\n",argv[3],argv[1],argv[2],min(a,b));
else
printf("operate_flag should be max or min !");
}
*/
- (3)使用命令行参数
- //命令行参数使用。
- (3)使用命令行参数
- winrar 命令行参数使用
- VS使用命令行参数
- 【Python】命令行参数使用
- 使用getopt解析命令行参数
- 使用getopts获取命令行参数
- VS2010中使用命令行参数
- 使用 getopts 处理命令行参数
- VS2010中使用命令行参数
- Java(命令行参数使用)
- Kettle的命令行参数使用
- 使用getopt解析命令行参数
- Selenium参数化-使用命令行
- 使用argparse解析命令行参数
- glib命令行解析库简单使用--GOptionEntry 命令行参数
- java 命令行参数-main()函数-需要使用命令行
- n皇后问题递归算法(回溯法)
- Linux下编译MIPS compiler
- Android开发者应该深入学习的10个开源应用项目
- 并行计算 基本概念
- Linux常见面试题
- //命令行参数使用。
- 个人理解 java虚拟机中的符号引用和直接引用
- // c 程序设计设计 教材例8.16 指向函数的指针。 实现同一函数,根据参数执行不同的子函数。
- hdu 1010 Tempter Of TheBone
- // 函数指针的使用,使用c++编译器。
- 堆排序
- java 设计模式学习笔记十 bridge桥模式
- 如何在iOS中使用libxml
- iphone__game center 多人游戏