Advertisement
akass

Truble

Apr 26th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. // ConsoleApplication2.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9.   char *myString="55552222"; // длинная строка
  10.     char cod[5] = "0000";
  11.     char s1[5];
  12.     char s2[5];
  13.    
  14.     int cnt = 0;
  15.     char next='0';
  16.  
  17.     while (next != 0) // цикл для проверки длины строки, cnt длина
  18.     {
  19.         next = myString[cnt];
  20.         if (next != 0)
  21.         {
  22.             cnt++;
  23.         }
  24.     }
  25.  
  26.    
  27.     if ((cnt)==8)
  28.     {
  29.         for (int i = 0; i <= 3; i++)
  30.         {
  31.             s1[i] = myString[i]; // первая половина строки
  32.             s2[i] = myString[i + 4]; // вторая
  33.         }
  34.         s1[4] = 0;
  35.         s2[4] = 0;
  36.         if (strcmp(s1, "5555") == 0)
  37.         {
  38.             memset(cod, 0, 5);// не работает
  39.             strcpy_s(cod, s2);// не работает
  40.         }
  41.     }
  42.     printf("%s", cod);
  43.  
  44.     getchar();
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement