SHOW:
|
|
- or go back to the newest paste.
1 | #include<stdio.h> | |
2 | - | #include<string.h> |
2 | + | void main() { |
3 | - | //#incldue<ctype.h> |
3 | + | char com[30]; |
4 | - | void main() |
4 | + | int i=2,a=0; |
5 | printf("\n Enter comment:"); | |
6 | - | char exp[50]="\0",con[50]="\0",kwd[50]="\0",id[50]="\0",sym[50]="\0",opr[50]="\0"; |
6 | + | gets(com); |
7 | - | char key[6][10]={"if","for","do","while","int","float"}; |
7 | + | if(com[0]=='/') { |
8 | - | char ch; |
8 | + | if(com[1]=='/') |
9 | - | char ptr[10][10]={"\0"}; |
9 | + | printf("\n It is a comment"); |
10 | - | int i=0,j=0,k=-1,n=-1,p=-1,s=-1; |
10 | + | else if(com[1]=='*') { |
11 | - | puts("Enter expression::"); |
11 | + | for(i=2;i<=strlen(com);i++) |
12 | - | gets(exp); |
12 | + | |
13 | - | puts("\n Tokens are::"); |
13 | + | if(com[i]=='*'&&com[i+1]=='/') |
14 | - | do |
14 | + | |
15 | - | { |
15 | + | printf("\n It is a comment"); |
16 | - | ch=exp[i]; |
16 | + | a=1; |
17 | - | if(isalpha(ch)) |
17 | + | break; } |
18 | - | { |
18 | + | else |
19 | - | k=-1; |
19 | + | continue; } |
20 | - | ptr[++n][++k]=ch; |
20 | + | if(a==0) |
21 | - | i++; |
21 | + | printf("\n It is not a comment"); |
22 | - | ch=exp[i]; |
22 | + | } |
23 | - | if(isalpha(ch)||isdigit(ch)) |
23 | + | else |
24 | - | { |
24 | + | printf("\n It is not a comment"); |
25 | - | while(isalpha(ch)||isdigit(ch)) |
25 | + | } |
26 | - | { |
26 | + | else |
27 | - | ptr[n][++k]=ch; |
27 | + | printf("\n It is not a comment"); |
28 | - | i++; |
28 | + |