online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <cstring> #include <vector> int main() { /* Copy initialisation using copy constructor of string */ std::string str = "rose"; /* Direct initialisation */ std::string str2("shirley"); std::cout << "str " << str << " str2 " << str2 <<std::endl; std::string str22(str2.begin(), str2.end()); std::cout << "str22 " << str22 << std::endl; /* String initialisation by assigning specific indices of other string */ std::string str3(str2, 3, 6); std::cout << "str3 " << str3 << " str2 " << str2 <<std::endl; /* Operator Overloading */ std::string str4 = str2 + " is trying to" " unravel certain problems"; std::cout << "str4 " << str4 << std::endl; /* Get the substring of 10 letters from 10th index substr(index, noOfLetters) */ std::string str5 = str4.substr(11, 10); std::cout << "str5 " << str5 << std::endl; /* Convert string to const char* - Method 1 */ std::string str6 = "hello"; const char *c = str6.c_str(); std::cout << "char " << c << std::endl; /* Convert string to char* - Method 2 */ std::string str7 = "world"; char *c1 = new char[str7.length()]; strcpy(c1, str7.c_str()); std::cout << "char " << c1 << std::endl; delete []c1; /* Convert string to vector of chars - Method 3 */ std::vector<char> v1(str7.begin(), str7.end()); for (auto &c : v1) { std::cout << c << " "; } std::cout << std::endl; /* Convert string to char - Method 4 */ std::string str8 = "bellow"; char c2 = str8[0]; std::cout << "char " << c2 << std::endl; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue