2012-12-04 72 views
0

我正在爲OPNET工作,爲此,我需要在ANSI C語言中的相當於getopt()函數的窗口。getopt()在ANSI C

我需要調用getopt()類似像:

while ((opt = getopt(argc, argv, "hadp:s")) != -1) { 
    switch (opt) { 
     case 'a': 
      break; 
     case 'd': 
      dummy = 1; 
      break; 
     case 'p': 
      res = atoi(optarg); 
      if (1 <= res) 
       break; 
      else 
       usage(argv[0]); 
       break; 
     case 's': 
      use_decimal = 0; 
      break; 
     case 'h': 
     default: 
      usage(argv[0]); 
    } 
} 

現在,當我編譯,我得到錯誤getopt()是不確定的。我定義了它的頭文件,但它不能包含在OPNET中。所以,我想問,我應該如何克服這個問題。

+0

你能發佈確切的錯誤信息嗎 – knightrider

+0

你收錄了這個文件#include Omkant

+0

我得到這個錯誤:getopt is undefined;假設extern返回int – Farhan

回答