Advertisement
dllbridge

Untitled

Feb 23rd, 2025
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1.  
  2. #include   <stdio.h>
  3. #include   <cstring>
  4. #include  <stdlib.h>
  5.  
  6.  
  7.  
  8. char sz[9999];
  9.    
  10. int push(const char*p);
  11. void monitor(int s);
  12.  
  13.  
  14.  
  15.  
  16. //////////////////////////////////////////////////////////
  17. struct M
  18. {
  19.     int c;  // Длина строки / кол-во букв
  20.     int b;  // Адрес строки
  21. };
  22.  
  23.  
  24.    
  25. M t[10];
  26.  
  27. ///////////////////////////////////////////////////////////
  28. int main()
  29. {
  30.    
  31.     struct M *p = (M*)malloc(sizeof(struct M));
  32.    
  33.         push("our,");
  34.         push("sailor,");
  35.         push("save,");
  36.         push("soul,");
  37.         push("stop,");
  38.         push("Flash");
  39.         push("Jack");
  40.         push("peas");  
  41.        
  42.         for(int i = 7; i >= 0; i-- )
  43.         {
  44.             monitor(i);
  45.         }
  46. }
  47.  
  48.  
  49.  
  50. //////////////////////////////////////////////////////////////
  51.  int push(const char *p)
  52. {
  53.      
  54.     static int ncounter = 0;
  55.     static int offset   = 0;
  56.            int x        = strlen(p);
  57.            
  58.     t[ncounter].c       = x;
  59.     t[ncounter].b       = offset;
  60.                  offset = offset + x;
  61.    
  62.  //   printf("%d\n", x);
  63.     strcat(sz, p);
  64.     ncounter ++;
  65.    
  66. return ncounter;
  67. }
  68.  
  69. ////////////////////////////////////////////////////////////////
  70. void monitor(int s)
  71. {
  72.      printf("%d = ", t[s].c);
  73.      printf("%.*s\n",t[s].c, t[s].b + sz);
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement