Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- int _tmain(int argc, _TCHAR* argv[])
- {
- char *myString="55552222"; // длинная строка
- char cod[5] = "0000";
- char s1[5];
- char s2[5];
- int cnt = 0;
- char next='0';
- while (next != 0) // цикл для проверки длины строки, cnt длина
- {
- next = myString[cnt];
- if (next != 0)
- {
- cnt++;
- }
- }
- if ((cnt)==8)
- {
- for (int i = 0; i <= 3; i++)
- {
- s1[i] = myString[i]; // первая половина строки
- s2[i] = myString[i + 4]; // вторая
- }
- s1[4] = 0;
- s2[4] = 0;
- if (strcmp(s1, "5555") == 0)
- {
- memset(cod, 0, 5);// не работает
- strcpy_s(cod, s2);// не работает
- }
- }
- printf("%s", cod);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement