MIPI_BaseC_WebinarFRTK/12_Lecture12/01_argc_argv_p8.c

27 lines
643 B
C
Raw Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
int main(int argc, char *argv[])
{
int size=0;
for(int i=0; i<argc; i++)
{
printf("argc = %d, argv = %s\n", i, argv[i]);
char* str = argv[i];
if(str[0]=='-')
switch (str[1])
{
case 'h'/* constant-expression */:
/* code */
printf("HELP\n");
break;
case 's':
sscanf(argv[i+1],"%d",&size);
printf("%d %s %d\n",size,argv[i+1],i+1);
break;
default:
break;
}
}
return 0;
}