检查ARGC价值 [英] Checking value of argc

查看:205
本文介绍了检查ARGC价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与传递给编程结果ARGC的数量问题
所以,当我检查的argc这不是等于2!结果
需要帮助,我怎么能解决这个问题?

C $ C $Ç片段:

 如果(2!= ARGC){
    fprintf中(标准错误,用法:%S<港口> \\ N的argv [0]);
    出口(1);
}


解决方案

不要忘了,节目名称本身作为一个ARG重要的。

myProgram -flag变量 ARGC 3

I have problem with the number of argc that passed to program
so, when i check the argc it's not equal to 2 !!
need help, how can i solve that problem ?

C code snippet :

if (2 != argc) {
    fprintf(stderr, "Usage: %s <port>\n", argv[0]);
    exit(1);
}

解决方案

Don't forget that the program name itself counts as an arg.

myProgram -flag variable is an argc of 3

这篇关于检查ARGC价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆