Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <cstdio>
- #include <string.h>
- using namespace std;
- char* change_of_string(char string1[])
- {
- char result[300] = { "" };
- int counter = 0;
- int n;
- for (int i = 0; i < strlen(string1); i++)
- {
- counter = 0;
- char numbers[20] = { "" };
- while (isdigit((int)string1[i]))
- {
- numbers[counter] = string1[i];
- counter++;
- i++;
- }
- if (counter > 0)
- {
- i--;
- n = atoi(numbers);
- _itoa(n, numbers, 16);
- strcat(result, "0x");
- strcat(result, numbers);
- }
- else
- strncat(result, &string1[i], 1);
- }
- return result;
- }
- void assertion(string test, char string1[])
- {
- char result[100];
- strcpy(result, change_of_string(string1));
- if (result == test)
- cout << "ok" << endl;
- else
- cout << "no" << endl;
- }
- int main()
- {
- assertion("as0x11df0x50", "as17df80");
- assertion("0x18sdadsf0x123df", "24sdadsf291df");
- assertion("0x6ae2b7e4", "1793243108");
- assertion("asdfkjhgfuytewryfdsdffg", "asdfkjhgfuytewryfdsdffg");
- assertion("", "");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement