- 论坛徽章:
- 0
|
- while((ch=getopt(argc,argv,"n:N:"))!=-1)
- {
- switch(ch)
- {
- case 'n':
- case 'N':
- printf("111111111111111111\n");
- //scanf("%d",p_num);
- //pthread_num=p_num;
- //printf("pthread_num=%d\n",pthread_num);
- if(strcmp(opt,"sss")==0)
- {
- printf("2222222222222222\n");
- pthread_num=3;
- swork();
- }
- //swork();
- return 0;
- break;
- default:
- printf("You input err num\n");
- break;
- }
- }
复制代码 这是我在main里写的函数,我的目的就是要获取./a -n 3 这里的数字3,我要赋值给pthread_num,不知道要怎么做,现在贴出来的代码,我只想进到if语句里,编译完在终端输入./a -n sss log信息显示1111111111,opt我是这样定义的char *opt,还报了一个Segmentation fault (core dumped)的错误,请大侠帮忙,我要怎么获取这个数字3,现在问题出在哪了 |
|