Advertisement
SteelK

Untitled

Mar 9th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5. char* newstr(char*temp){
  6.     int i = 0, j = 0, N;
  7.     N = strlen(temp) + 1;
  8.     char *str = new char[N];
  9.     strcpy(str, temp);
  10.     delete[]temp;
  11.     char* fin_string = new char[N];
  12.     while (i != N)
  13.     {
  14.         if (str[i] != '<')
  15.         {
  16.             fin_string[j] = str[i];
  17.             i++;
  18.             j++;
  19.         }
  20.         else
  21.         {
  22.             fin_string[j] = str[i];
  23.             i++;
  24.             j++;
  25.             while (str[i] != '>')
  26.                 i++;
  27.             fin_string[j] = str[i];
  28.             i++;
  29.             j++;
  30.         }
  31.     }
  32.     return fin_string;
  33.     delete[]str;
  34. }
  35.  
  36. int main()
  37. {
  38.     cout << "Input string" << endl;
  39.     char * temp = new char[256];
  40.     gets(temp);
  41.     char*fin_string = newstr(temp);
  42.     cout << "Well done, fine human. Your new string is down here:  " << endl << fin_string << endl;
  43.     delete[]fin_string;
  44.     system("pause");
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement