Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void newStrings(Item *p, Item *pptr1, Item *pptr2) {
- Item head = { '*', p };
- Item head_n = { '*' };
- Item head_c = { '*' };
- Item *last_n = &head_n;
- Item *last_c = &head_c;
- Item *cur = &head;
- cur = cur->next;
- int fl = 1;
- while (cur) {
- if (cur->c == ' ' || cur->c == '\t') {
- cur = delSpace(cur);
- if (fl==1) {
- Item *buf = cur;
- cur = cur ->next;
- free(buf);
- fl = 0;
- continue;
- }
- if (cur->next == NULL) {
- free(cur);
- break;
- }
- last_n->next = cur;
- last_n = last_n->next;
- char buf[] = { ' ', '\0' };
- last_c->next = (Item *)malloc(sizeof(Item));
- last_c = last_c->next;
- last_c->c = *buf;
- last_c->next = NULL;
- }
- else {
- if (fl == 1)
- fl = 0;
- if (cur->c == '1' || cur->c == '2' || cur->c == '3' || cur->c == '4' || cur->c == '5' || cur->c == '6' || cur->c == '7' || cur->c == '8' || cur->c == '9' || cur->c == '0') {
- last_n->next = cur;
- last_n = last_n->next;
- }
- else {
- last_c->next = cur;
- last_c = last_c->next;
- }
- }
- cur = cur->next;
- }
- last_n->next = NULL;
- last_c->next = NULL;
- putList("Result string1", head_n.next);
- putList("Result string2", head_c.next);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement