//命令行参数使用。

//命令行参数使用。 
//将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 !");
}

 
*/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值