problems on polish notation
i have an algorithm on polish notation
content of the file eq.txt
i will open the code using file io
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <iostream.h>
#include "stack.h"
void main()
{
clrscr();
char str[1500], file[10], sfile[10];
int x;
FILE *fp1, *fp2;
printf("Enter filename:");
gets(file);
fp1=fopen(file,"r");
printf("Save to:");
gets(sfile);
fp2=fopen(sfile,"w");
if(fgets(str, sizeof(str), fp1)!=NULL)
{
fputs(str,fp2);
printf("Content is:\n %s", str);
}
else
{
printf("cannot open file!!!");
}
fclose(fp1);
fclose(fp2);
getch();
}
the result is the equation ((3+2)*5)+5
but if this program reads the equation which is the content of the file and the output of this program will be the result of this equation
Code:
((3+2)*5)5+5
(5*5)+5
25+5
30