Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将一串数字(我的意思是字符串而不是 char,因为 atoi 函数适用于 char ,而对我来说不适用于字符串)为整数。我试过了,但没有用:
int main(){ int P,W; string ST1 , ST2; getline(cin,ST1,' '); getline(cin,ST2); P = std::atoi(ST1); W = std::atoi(ST1); return 0 ; }
您可以使用 using调用任何采用 aconst char *的函数:string.c_str()
const char *
string
.c_str()
P = std::atoi(ST1.c_str());