Question: The code runs fine. I just need some comments for the functions Keyword and main so that I can explain the code to a friend

The code runs fine. I just need some comments for the functions Keyword and main so that I can explain the code to a friend

#include #include #include #include int isKeyword(char buffer[]){ char keywords[32][10] = {"auto","break","case","char","const","continue","default", "do","double","else","enum","extern","float","for","goto", "if","int","long","register","return","short","signed", "sizeof","static","struct","switch","typedef","union", "unsigned","void","volatile","while"}; int i, flag = 0; for(i = 0; i < 32; ++i){ if(strcmp(keywords[i], buffer) == 0){ flag = 1; break; } } return flag; } int main(){ char ch, buffer[15], operators[] = "+-*/%="; FILE *fp; int i,j=0; fp = fopen("program.txt","r"); if(fp == NULL){ printf("error while opening the file "); exit(0); } while((ch = fgetc(fp)) != EOF){ for(i = 0; i < 6; ++i){ if(ch == operators[i]) printf("%c is operator ", ch); } if(isalnum(ch)){ buffer[j++] = ch; } else if((ch == ' ' || ch == ' ') && (j != 0)){ buffer[j] = '\0'; j = 0; if(isKeyword(buffer) == 1) printf("%s is keyword ", buffer); else printf("%s is indentifier ", buffer); } } fclose(fp); return 0; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!