Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*8. Napisati program koji pomoću vezanih listi (stabala) predstavlja strukturu direktorija.
- Omogućiti unos novih direktorija i pod-direktorija, ispis sadržaja direktorija i
- povratak u prethodni direktorij. Točnije program treba preko menija simulirati
- korištenje DOS naredbi: 1- "md", 2 - "cd dir", 3 - "cd..", 4 - "dir" i 5 – izlaz.
- */
- #define _CRT_SECURE_NO_WARNINGS
- #define MAXCHAR 100
- #include<stdio.h>
- #include<errno.h>
- #include<string.h>
- #include<stdlib.h>
- typedef struct Node;
- typedef struct Node* Position;
- struct Node
- {
- char Name[MAXCHAR];
- Position Sibling;
- Position Child;
- };
- //ClearScren
- void clrscr()
- {
- system("@cls||clear");
- }
- //Funkcije
- int create_New();
- int change_directory(Position P, char *buff);
- int main()
- {
- char buffer[MAXCHAR], exit = "Exit";
- char *function;
- char *file_name;
- struct Node Stack, P,temp;
- Stack.Child = NULL;
- Stack.Sibling = NULL;
- P.Child = NULL;
- P.Sibling = NULL;
- int x = 1;
- while (x==1)
- {
- //clrscr();
- //Ovde dolazi onaj dio koji definira ono c:\nesto\nesto>
- //Ovde znaci dodje ono citanje iz stoga pa ide redom u while petlji
- printf(">");
- scanf("%[^\n]", buffer);
- getchar();
- printf("%s", buffer);
- function = strtok(buffer," ");
- //printf(" %s", function);
- if (strcmp(function, "md")==0)
- {
- Position q;
- q = (Position)malloc(sizeof(struct Node));
- if (NULL == q)
- {
- printf("Greska prilikom alokacije memorije\n");
- }
- file_name = strtok(NULL, " ");
- strcpy(q->Name, file_name);
- q->Sibling = &P.Child;
- P.Child = q;
- //printf(" %s", q->Name);
- //printf("Funkcija je Make dir");
- }
- else if (strcmp(function,"cd") == 0)
- {
- }
- else if (strcmp(function,"cd..") == 0)
- {
- }
- else if (strcmp(function,"dir") == 0)
- {
- }
- else if (strcmp(function,"Exit") == 0)
- {
- x = 0;
- }
- memset(buffer,' ', MAXCHAR);
- }
- getchar();
- getchar();
- return 0;
- }
- int create_New()
- {
- return 1;
- }
- int change_directoy(Position P, char *buff)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement