if-else条件语句 [英] if-else conditional statements
本文介绍了if-else条件语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在此代码中添加第三个参数,我该怎么做?
I want to add a third argument to this code, how would I do it?
{
if ( !_stricmp(_argv[1], "icmp") )
bShowTCP = FALSE;
else if ( !_stricmp(_argv[1], "tcp") )
bShowICMP = FALSE;
else
{
printf( "\nUsage lsniff [ICMP|TCP]\n" );
exit(0);
}
}
像这样,但不起作用.....
Like This, but not working.....
{
if ( !_stricmp(_argv[1], "icmp") )
bShowTCP = FALSE;bShowUDP = FALSE:
else if ( !_stricmp(_argv[1], "tcp") )
bShowICMP = FALSE;bShowUDP = FALSE;
else
bShowUDP = TRUE;
{
printf( "\nUsage lsniff [ICMP|TCP]\n" );
exit(0);
}
}
逻辑如下...
如果是ICMP,则TCP和UDP = False
如果是TCP,则ICMP和UDP = False
如果UDP,则ICMP和TCP = False
The logic is as follows...
If ICMP then TCP and UDP = False
If TCP then ICMP and UDP = False
If UDP then ICMP and TCP = False
推荐答案
我认为您要执行的操作是在条件语句中添加额外的代码:
I think what you''re trying to do is add extra code to the conditional statements:
if ( !_stricmp(_argv[1], "icmp") )
{ //<-- Need to add brackets for more than one statement
bShowTCP = FALSE;
bShowUDP = FALSE;
}
else if ( !_stricmp(_argv[1], "tcp") )
{
bShowICMP = FALSE;
bShowUDP = FALSE;
}
else
{
bShowUDP = TRUE; //<-- Needs to be within else statement brackets
printf( "\nUsage lsniff [ICMP|TCP]\n" );
exit(0); //<-- FYI... this ends execution of the program
}
这篇关于if-else条件语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文