-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesti2p.c
37 lines (26 loc) · 944 Bytes
/
testi2p.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "infix-to-postfix.h"
#include "stack.h"
int main(int argc, char *argv[]) {
// initialize an empty infix array
char infix[256];
// initialize an empty postflix array
char postfix[256];
printf("\n\n=================================================\n");
printf("Infix to Postfix Testing! \n");
printf("=================================================\n");
strncpy(infix, "j * j + 10 / 5 * ( 5 - 4 )", 256) ;
printf("Our infix is: %s\n", infix);
convertToPostfix(infix, postfix);
printf("Our changed postfix is: %s\n", postfix);
printf("\n");
printf("\n");
strncpy(postfix, "10 10 + 5 / 4 *" , 256) ;
printf("Now we will evaluate the expression %s:\n", postfix);
int result = evaluatePostfixExpression(postfix);
printf("The result is %d", result);
printf("\n");
}