Advertisement
SteelK

Untitled

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