2010-10-14 46 views
2

我有一些代碼GDB打印不一致

int main(int argc, char* key[]) { 
cout << strlen(key[1]) << endl; 

COUT顯示4.

現在用gdb

(gdb)print strlen(key[1]) 

顯示-147660784
什麼是造成這種差異的原因嗎?

+0

完全重複的:http://askubuntu.com/questions/27019/strlen-returns-incorrect-value-when-called-in-gdb – karlphillip 2011-03-31 23:59:39

+0

此問題與程序員使用的工具有關,它完全針對主題對於SO(即使它已經在另一個站點上詢問)。 – 2011-04-01 07:48:57

回答