主函数main(argc,argv)中,两个参数是如何确定的

主函数main(argc,**argv)中,两个参数是怎么确定的?
#include <stdlib.h>
#include <stdio.h>

#include <pcap.h>


int main(int argc, char **argv)
{
pcap_t *fp;
char errbuf[PCAP_ERRBUF_SIZE];
u_char packet[100];
int i;

/* Check the validity of the command line */
if (argc != 2)
{
printf("usage: %s interface", argv[0]);
return 1;
}
    
/* Open the adapter */
if ((fp = pcap_open_live(argv[1], // name of the device
 65536, // portion of the packet to capture. It doesn't matter in this case 
 1, // promiscuous mode (nonzero means promiscuous)
 1000, // read timeout
 errbuf // error buffer
 )) == NULL)
{
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[1]);
return 2;
}

/* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
packet[0]=1;
packet[1]=1;
packet[2]=1;
packet[3]=1;
packet[4]=1;
packet[5]=1;

/* set mac source to 2:2:2:2:2:2 */
packet[6]=2;
packet[7]=2;
packet[8]=2;
packet[9]=2;
packet[10]=2;
packet[11]=2;

/* Fill the rest of the packet */
for(i=12;i<100;i++)
{
packet[i]= (u_char)i;
}

/* Send down the packet */
if (pcap_sendpacket(fp, // Adapter
packet, // buffer with the packet
100 // size
) != 0)
{
fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp));
return 3;
}

pcap_close(fp);
return 0;
}

在调试以上Wincap的数据包发送代码时,每次都进入到
if (argc != 2)
{
printf("usage: %s interface", argv[0]);
return 1;
}

下面的代码根本就不会运行了。
想知道main的argc参数是如何确定的?什么情况下才能等于2呢?
------最佳解决方案--------------------
在‘设置’‘Debug’ ‘程序参数Program arguments’ 中 输入 参数。
------其他解决方案--------------------
gcc target.c 就会生成a.out 执行的时候 ./a.out 即为argv[0] ,看这段程序需要个参数 ./a.out val 即可。
------其他解决方案--------------------
这个根据你执行程序时候后面的入参数量来决定argc的值,另外argv[1]表示第一个参数指针。

a.exe "abc" "efc"

这个时候就是2个入参,2个参数指针。
------其他解决方案--------------------
看下crtexe.c的代码不就清楚了
------其他解决方案--------------------
带参数运行的,命令行下带参数那样:abc.exe -i -a
------其他解决方案--------------------
引用:
这个根据你执行程序时候后面的入参数量来决定argc的值,另外argv[1]表示第一个参数指针。

a.exe "abc" "efc"

这个时候就是2个入参,2个参数指针。

正解...
也可在DEBUG调试时输入参数
------其他解决方案--------------------
引用: