W
Wally
int main(int argc, char *argv[]) {
int c;
int port=0;
char *srvname = NULL;
extern char *optarg;
/*
**Determine whether we are converting a port
**number to a server name or vice versa.
*/
while ( (c = getopt(argc, argv, "nh")) != -1) {
switch(c) {
case 'p': port = *optarg;
printf("port number is %d\n",port);
break;
case 'n': srvname = *optarg;
printf("server name is %s\n",srvname);
break;
case '?': usage();
break;
default: usage();
}
}
}
I get a segmentation fault with the p or n option. Any help would be
appreciated.
int c;
int port=0;
char *srvname = NULL;
extern char *optarg;
/*
**Determine whether we are converting a port
**number to a server name or vice versa.
*/
while ( (c = getopt(argc, argv, "nh")) != -1) {
switch(c) {
case 'p': port = *optarg;
printf("port number is %d\n",port);
break;
case 'n': srvname = *optarg;
printf("server name is %s\n",srvname);
break;
case '?': usage();
break;
default: usage();
}
}
}
I get a segmentation fault with the p or n option. Any help would be
appreciated.