Advertisement
SteelK

Untitled

Mar 10th, 2016
55
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.  
  6. char* newstr(char*temp){
  7.     int i = 0, j = 0, N;
  8.     N = strlen(temp) + 1;
  9.     char *str = new char[N];
  10.     strcpy(str, temp);
  11.     delete[]temp;
  12.     char* fin_string = new char[N];
  13.     while (i != N)
  14.     {
  15.         if (str[i] != '<')
  16.         {
  17.             fin_string[j] = str[i];
  18.             i++;
  19.             j++;
  20.         }
  21.         else
  22.         {
  23.             fin_string[j] = str[i];
  24.             i++;
  25.             j++;
  26.             while (str[i] != '>')
  27.                 i++;
  28.             fin_string[j] = str[i];
  29.             i++;
  30.             j++;
  31.         }
  32.     }
  33.     return fin_string;
  34.     delete[]str;
  35. }
  36.  
  37. int main()
  38. {
  39.     cout << "Input string" << endl;
  40.     char * temp = new char[256];
  41.     gets(temp);
  42.     char*fin_string = newstr(temp);
  43.     cout << "Well done, fine human. Your new string is down here:  " << endl << fin_string << endl;
  44.     delete[]fin_string;
  45.     system("pause");
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement