Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #define SIZE 200
- typedef struct List {
- char* rech;
- struct List* next, * prev;
- } LIST;
- LIST* head = NULL;
- void Input(LIST* p);
- void AddElem(pnew);
- void PrintList();
- int main()
- {
- Input(head);
- PrintList();
- return 0;
- }
- void Input(LIST* p)
- {
- char buf[SIZE] = { "" };
- A:
- p = (LIST*)malloc(sizeof(LIST));
- if (head == NULL) {
- p->prev = p->next = NULL;
- head = p;
- }
- if (*gets_s(buf, SIZE) != '\0') {
- fflush(stdin);
- gets(buf);
- p->rech = (char*)malloc(strlen(buf) + 1);
- strcpy(p->rech, buf);
- AddElem(p);
- goto A;
- }
- else {
- return;
- }
- }
- void AddElem(LIST* pnew)
- {
- head->prev = pnew;
- pnew->next = head;
- pnew->prev = NULL;
- head = pnew;
- return;
- }
- void PrintList()
- {
- LIST* p = head;
- printf("%s", p->rech);
- /*while (p != NULL) {
- printf("\n%s", p->rech);
- p = p->next;
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement