Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cstring>
- #include <stdlib.h>
- char sz[9999];
- int push(const char*p);
- void monitor(int s);
- //////////////////////////////////////////////////////////
- struct M
- {
- int c; // Длина строки / кол-во букв
- int b; // Адрес строки
- };
- M t[10];
- ///////////////////////////////////////////////////////////
- int main()
- {
- struct M *p = (M*)malloc(sizeof(struct M));
- push("our,");
- push("sailor,");
- push("save,");
- push("soul,");
- push("stop,");
- push("Flash");
- push("Jack");
- push("peas");
- for(int i = 7; i >= 0; i-- )
- {
- monitor(i);
- }
- }
- //////////////////////////////////////////////////////////////
- int push(const char *p)
- {
- static int ncounter = 0;
- static int offset = 0;
- int x = strlen(p);
- t[ncounter].c = x;
- t[ncounter].b = offset;
- offset = offset + x;
- // printf("%d\n", x);
- strcat(sz, p);
- ncounter ++;
- return ncounter;
- }
- ////////////////////////////////////////////////////////////////
- void monitor(int s)
- {
- printf("%d = ", t[s].c);
- printf("%.*s\n",t[s].c, t[s].b + sz);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement