Created
October 26, 2016 04:05
-
-
Save izumin5210/3f610c6f69ab9b20b7059b948490d229 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
int main() | |
{ | |
const std::string id = "#3"; | |
std::cout << "id // => " << id << std::endl; | |
std::cout << "id[0] // => " << id[0] << std::endl; | |
std::cout << "id.c_str() // => " << id.c_str() << std::endl; | |
std::cout << "(id.c_str() + 1) // => " << (id.c_str() + 1) << std::endl; | |
std::cout << "(id.c_str() + 2) // => " << (id.c_str() + 2) << std::endl; | |
std::cout << "atoi(id.c_str()) // => " << atoi(id.c_str()) << std::endl; | |
std::cout << "atoi(id.c_str() + 1) // => " << atoi(id.c_str() + 1) << std::endl; | |
std::cout << "(atoi(id.c_str()) - 1) // => " << (atoi(id.c_str()) - 1) << std::endl; | |
std::cout << "(atoi(id.c_str() + 1) - 1) // => " << (atoi(id.c_str() + 1) - 1) << std::endl | |
/** | |
* id // => #3 | |
* id[0] // => # | |
* id.c_str() // => #3 | |
* (id.c_str() + 1) // => 3 | |
* (id.c_str() + 2) // => | |
* atoi(id.c_str()) // => 0 | |
* atoi(id.c_str() + 1) // => 3 | |
* (atoi(id.c_str()) - 1) // => -1 | |
* (atoi(id.c_str() + 1) - 1) // => 2 | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment