實現一個函數,把一個字符串轉換成整數

做者:翁鬆秀web 劍指offer之「把一個字符串轉換成整數」 不少人看到這麼簡單的面試題目,都是大筆一揮,立馬寫下洋洋灑灑函數:面試 int StringToInt(char* string){ int num = 0; while(*string!='\0'){ num = num*10 + *string - '0'; string++;
相關文章
相關標籤/搜索