Is there a simpler method?
Code:vector<string> Size; char *s = strdup(Size[i].c_str()); long long num = _strtoi64(s, NULL, 10);
Is there a simpler method?
Code:vector<string> Size; char *s = strdup(Size[i].c_str()); long long num = _strtoi64(s, NULL, 10);
Using Windows 10 with Code Blocks and MingW.
If your standard library implementation conforms sufficiently to C++11, you could write:
Code:vector<string> Size; // ... long long num = stoll(Size[i]);
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
You don't need char* in the first place. _strtoi64 (which is bad function to use, btw) takes a const char*, because it doesn't change its parameters. Therefore, simply calling c_str() should suffice.
Also, to duplicate a string, all you need is to simply declare another string and assign the old one to it.