زبان : C -برنامه ای که برنامه دیگری را به عنوان فایل ورودی می پذیرد
#include
#include
#include
int main(int argc, char *argv[])
{
FILE *in ;
char ch;
int openbraket = 0, closebraket = 0;
int openparant = 0, closparant = 0;
clrscr();
if(argc != 2) {
printf("the number of arguments is incorrect.");
getch();
exit(1);
}
in = fopen(argv[1],"r");
if (!in) {
printf(" file cannot open!.");
getch();
exit(0);
}
ch = getchar();
while (!feof(in)) {
if (ch == '{')
openbraket ++ ;
else if (ch == '}')
closebraket ++;
else if (ch == '(')
openparant ++;
else if (ch == ')')
closparant ++;
ch = getc(in);
}
printf(" the number of open braket is:%d", openbraket);
printf("\n the number of close braket is:%d", closebraket);
printf("\n the number of open parentheses is:%d", openparant);
printf("\n the number of close parantheses is:%d", closparant);
fclose(in);
getch();
return 0;
}