我得到了下面的代碼,因爲我試圖理解getopt_long的用法。一切似乎都很好,但我得到了「預期」;'在返回之前「。我錯過了什麼?謝謝你們。';'在返回之前
int next_option;
const string short_options = "a:bcde";
const struct option long_options[] =
{
{"op1", 1, NULL, 'a'},
{"op2", 1, NULL, 'b'},
{"op3", 1, NULL, 'c'},
{"op4", 0, NULL, 'd'},
{"op5", 0, NULL, 'e'},
{ NULL,0, NULL, 0}
};
do
{
next_option = getopt_long(argc,argv,short_options.c_str(),long_options,NULL);
switch(next_option)
{
case 'a':
cout <<" ";
break;
case 'b':
cout <<" ";
break;
case 'c':
cout <<" ";
break;
case 'd':
cout <<" ";
break;
case 'e':
cout <<" ";
break;
case '?': // invalid option
cout <<" ";
break;
case -1: //no more option
cout <<" ";
break;
default:
cout <<" ";
break;
}
}
while(next_option!=-1)
return 0;
我必須遵循什麼程序來幫助我解決這類錯誤?
這是如何本地化...這不是第一次也不是最後一次有人會得到這個錯誤。 –