Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <Windows.h>
- using namespace std;
- void revSubStr(char* text){
- char *oldtext = new char[100];
- char enter_id;
- char* end_id = new char[1];
- cout << "Enter position #1: ";
- cin >> enter_id;
- cout << "Enter position #2: ";
- cin >> end_id;
- for (int i(0); i <= strlen(text); i++)
- {
- oldtext[i] = text[i];
- /* if (strchr(oldtext, enter_id) == NULL)
- {
- cout << "ERROR! NO SUCH THING AS '" << enter_id << "' IN SENTENSE!"<<endl;
- exit(0);
- }*/
- }
- char* a1 = strchr(text, enter_id);
- cout << "text: " << text << endl;
- char* a3 = strtok(a1, end_id);
- char* a4 = strcat(a3, end_id);
- int index = strcspn(text, a4);
- int riz = strcmp(a1, text) + index;
- char* reverse = strrev(a4);
- int lenght = strlen(oldtext);
- for (int i(0); i < strlen(reverse); i++)
- {
- oldtext[index + i] = reverse[i];
- }
- cout << "result end : " << oldtext << endl;
- delete[] oldtext, end_id;
- }
- void main()
- {
- const char n = 100;
- char text[n];
- cout << "Enter string: ";
- cin.getline(text, 100);
- revSubStr(text);
- }
Add Comment
Please, Sign In to add comment