#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
int countL=0,countR=0;
fp=fopen("tbraces.c","r");
clrscr();
printf("\n File: tbraces.c\n\n");
if(fp!=NULL)
{
do
{
ch='d';
while(ch!=' ')
{
ch=getc(fp);
printf("%c",ch);
if(ch=='{') countL++;
if(ch=='}') countR++;
if(ch==EOF) break;
}
}while(ch!=EOF);
}
if(countL!=countR)
printf("\n\n* ERROR in the syntax of curly braces");
else
printf("\n\n* Curly braces is syntactically correct");
fclose(fp);
getch();
}
0 Comments