-
Notifications
You must be signed in to change notification settings - Fork 0
/
pause.c
63 lines (49 loc) · 1.38 KB
/
pause.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <string.h>
void echo (char x[]){
printf("%s\n",x);
}
void pause(){
printf("in pause \n");
char x;
x = getchar();
while(x != '\n'){
x=getchar();
}
}
int main(){
char* evaluation[30]; // where input is evaluated
for(int fill=0; fill<30;){
evaluation[fill]= NULL;
fill=fill+1;
}
//while(strcmp(evaluation[0],"quit")!=0){
printf("myShell> ");
//-----------------------------------------------------------------------
char buffer[30];
fgets(buffer,30,stdin); // get command
char* command = strtok(buffer," "); // break command down
int j=0;
while(command != NULL){ // while we still have commands
printf("%s\n",command); // print so i can see it happen step by step for testing
evaluation[j]= command;// fill evaluation arry with each token
j=j+1;
command = strtok(NULL," ");
}
//-------------------------------------------------------
for(int i=0;i<30;){
if(strcmp(evaluation[i],"pause")==0){
pause();
}
else if(strcmp(evaluation[i],"echo")==0){
printf("%s\n", evaluation[i+1]); // need to find out how to print a string and not just a word
}
if(evaluation[i+1]== NULL){
break;
}
i=i+1;
}
//}
//----------------------------------------------------------------------------
return 0;
}