-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.c
More file actions
46 lines (42 loc) · 663 Bytes
/
parse.c
File metadata and controls
46 lines (42 loc) · 663 Bytes
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int parse();
int main()
{
char str[20], prompt[ ]="vysh>>";
while(1){
printf("%s",prompt);
parse();
return 0;
}
}
int parse() {
char s[80],ch;
int i=0,d,j,token=0;
printf("Enter the command line arguments\n");
gets(s);
printf("\nToken:%d\t",++token);
while(s[i]!='\0'){
d=s[i];
if((d!=32) && (d!=34)){
printf("%c",d);
}
else if(d==32){
if((s[i]==' ') && (s[i+1]!='"')){
printf("\nToken:%d\t",++token);
}
}
else
if((d==34) && (d!=32)){
printf("\nToken:%d\t",++token);
i++;
while(s[i]!='"'){
printf("%c",s[i]);
i++;
}
}
i++;
}
return 0;
}