Advertisement
Crackbone

SP-Zadatak8 wip

Dec 31st, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.05 KB | None | 0 0
  1. /*8. Napisati program koji pomoću vezanih listi (stabala) predstavlja strukturu direktorija.
  2. Omogućiti unos novih direktorija i pod-direktorija, ispis sadržaja direktorija i
  3. povratak u prethodni direktorij. Točnije program treba preko menija simulirati
  4. korištenje DOS naredbi: 1- "md", 2 - "cd dir", 3 - "cd..", 4 - "dir" i 5 – izlaz.
  5. */
  6.  
  7.  
  8.  
  9.  
  10.  
  11. #define _CRT_SECURE_NO_WARNINGS
  12. #define MAXCHAR 100
  13.  
  14. #include<stdio.h>
  15. #include<errno.h>
  16. #include<string.h>
  17. #include<stdlib.h>
  18.  
  19.  
  20.  
  21.  
  22. typedef struct Node;
  23. typedef struct Node* Position;
  24.  
  25. struct Node
  26. {
  27.     char Name[MAXCHAR];
  28.     Position Sibling;
  29.     Position Child;
  30. };
  31.  
  32. //ClearScren
  33. void clrscr()
  34. {
  35.     system("@cls||clear");
  36. }
  37.  
  38.  
  39. //Funkcije
  40. int create_New();
  41. int change_directory(Position P, char *buff);
  42. int main()
  43. {
  44.     char buffer[MAXCHAR], exit = "Exit";
  45.     char *function;
  46.     char *file_name;
  47.     struct Node Stack, P,temp;
  48.     Stack.Child = NULL;
  49.     Stack.Sibling = NULL;
  50.     P.Child = NULL;
  51.     P.Sibling = NULL;
  52.    
  53.     int x = 1;
  54.     while (x==1)
  55.    
  56.     {
  57.         //clrscr();
  58.         //Ovde dolazi onaj dio koji definira ono c:\nesto\nesto>
  59.         //Ovde znaci dodje ono citanje iz stoga pa ide redom u while petlji
  60.         printf(">");
  61.         scanf("%[^\n]", buffer);
  62.         getchar();
  63.         printf("%s", buffer);
  64.         function = strtok(buffer," ");
  65.         //printf(" %s", function);
  66.  
  67.         if (strcmp(function, "md")==0)
  68.         {
  69.             Position q;
  70.             q = (Position)malloc(sizeof(struct Node));
  71.             if (NULL == q)
  72.             {
  73.                 printf("Greska prilikom alokacije memorije\n");
  74.             }
  75.             file_name = strtok(NULL, " ");
  76.             strcpy(q->Name, file_name);
  77.            
  78.             q->Sibling = &P.Child;
  79.             P.Child = q;
  80.  
  81.             //printf(" %s", q->Name);
  82.             //printf("Funkcija je Make dir");
  83.  
  84.         }
  85.         else if (strcmp(function,"cd") == 0)
  86.         {
  87.            
  88.         }
  89.         else if (strcmp(function,"cd..") == 0)
  90.         {
  91.  
  92.         }
  93.         else if (strcmp(function,"dir") == 0)
  94.         {
  95.  
  96.         }
  97.         else if (strcmp(function,"Exit") == 0)
  98.         {
  99.             x = 0;
  100.         }
  101.         memset(buffer,' ', MAXCHAR);
  102.        
  103.     }
  104.  
  105.     getchar();
  106.     getchar();
  107.     return 0;
  108. }
  109.  
  110.  
  111. int create_New()
  112. {
  113.  
  114.     return 1;
  115. }
  116.  
  117. int change_directoy(Position P, char *buff)
  118. {
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement