Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://pastebin.com/u/TheWhiteFang
- //sasi punya
- #include <iostream>
- #include <string.h>
- #include <string>
- using namespace std;
- int main()
- {
- // C Style
- char strArray[32] = {0};
- strcpy(strArray, "Electronics Engineering");
- int length = strlen(strArray);
- cout << "Before Erase (C style): " << strArray << endl;
- for(int i = 9; i < length; i++)
- {
- strArray[i] = strArray[i+1];
- }
- cout << "After Erase (C style): " << strArray << endl;
- // C++ Style
- string str01 = "Electronics Engineering";
- cout << "\nBefore Erase (C++ stye): " << str01 << endl;
- str01.erase(str01.begin() + 9);
- cout << "After Erase (C++ stye): " << str01 << endl;
- str01 = "L" + str01;
- cout << "\nAfter add at beginning (C++ style): " << str01 << endl;
- str01 = str01 + "S";
- cout << "After add at end (C++ style): " << str01 << endl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement