fork download
  1. #include<stdio.h>
  2. //#include<conio.h>
  3. #include<string.h>
  4.  
  5. int main()
  6. {
  7. char id[10],
  8. key[][50]={{"int"},{"float"},{"double"},{"char"},
  9. {"if"},{"do"},{"for"},{"while"},{"else"}},
  10. sep[50]={'{','}','(',')',';',','},
  11. op[50]={'-','+','*','/','<','>','='};
  12. char ch[10]={0};
  13. int i,j,k,parsed,keylen;
  14. FILE *fp1,*fp2;
  15. keylen=sizeof(key)/sizeof(key[0]);
  16. printf("//This program needs space & case sensitive input !! \nParsing tokens...");
  17. fp1=fopen("tokenFile.txt","r");
  18. while(fscanf(fp1,"%s",ch)!=EOF)
  19. {
  20. parsed=0;
  21. ch[strlen(ch)]=0;
  22. //printf("\n%s",ch);
  23. for(i=0;i<strlen(op)&&parsed==0;i++)
  24. {
  25. if(strstr(op,ch)) //strstr: finds ist occurance of str2 in str1
  26. {
  27. printf("\n%c :Operator",ch[0]);
  28. parsed=1;
  29. break;
  30. }
  31. }
  32. for(i=0;i<keylen&&parsed==0;i++)
  33. {
  34. if(strstr(ch,key[i]))
  35. {
  36. printf("\n%s :Keyword",ch);
  37. parsed=1;
  38. break;
  39. }
  40. }
  41. for(i=0;i<strlen(sep);i++)
  42. {
  43. if(strstr(sep,ch))
  44. {
  45. printf("\n%c :Separator",ch[0]);
  46. parsed=1;
  47. break;
  48. }
  49. }
  50. for(i=0;isdigit(ch[0])&&parsed==0;i++)
  51. {
  52. printf("\n%s :Constant",ch);
  53. parsed=1;
  54. break;
  55. }
  56. if(parsed==0)
  57. {
  58. printf("\n%s :Identifier",ch);
  59. parsed=1;
  60. }
  61. }
  62.  
  63. fclose(fp1);
  64. return 0;
  65. }
  66.  
  67.  
Runtime error #stdin #stdout 0s 10320KB
stdin
int i ; 
float a , b , c ;
for ( i = 0 ; i < n ; i + + )
{
	do {
		c = a * b ;			
	} while ( a > b );
}
stdout
Standard output is empty