Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- char * newstr(const char * newtemp)
- {
- int i = 0, j = 0, N;
- N = strlen(newtemp) + 1;
- char *str = new char[N];
- strcpy(str, newtemp);
- char* fin_string = new char[N];
- while (i != N)
- {
- if (str[i] != '<')
- {
- fin_string[j] = str[i];
- i++;
- j++;
- }
- else
- {
- fin_string[j] = str[i];
- i++;
- j++;
- while (str[i] != '>')
- i++;
- fin_string[j] = str[i];
- i++;
- j++;
- }
- }
- return fin_string;
- delete[]str;
- }
- int main()
- {
- if ((strcmp(newstr("Viktoria"), "Viktoria")) || (strcmp(newstr("<kuku>"), "<>")) || (strcmp(newstr("<>"), "<>")) || (strcmp(newstr(""), "")))
- {
- cout << "bad" << endl;;
- return 1;
- }
- cout << "Good" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement