We've been given a assignment at school and the while loop at the end of the code doesn't seem to give the value I expected.
#include <stdio.h>
#include <string.h>
int main() {
char str[50],storage[50][50]={0},temp[50]={0};
printf("Input Formula without space:");
gets(str);
int x=0, y=0,z=0,w,i,top=-1,max=strlen(str);
for(i=0;i<max;i++){
printf("Eyyyyyy");
top+=1;
switch(str[top]){
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '-':
case '+':
case '*':
case '/':
case '9':storage[x][y]=str[top];x++;break;
case ')':
if (x-3<0)
break;
else{
while(storage[x-3][y]!=0){
temp[y]=storage[x-3][y];
y++;
printf("Hey");};
storage[x-3][y]='(';
while (temp[y]!=0){
storage[x-3][y+1]=temp[y];
y++;
};
for (z=2;z>=0;z--){
while (storage[x-z][y]!=0){
w=strlen(storage[x-3]);
storage[x-3][w]=storage[x-z][y];
}
}
}
x-=3;
break;
}
}
for(i=0;i<20;i++){
printf("%c",storage[0][i]);
}
for(i=0;i<20:i++){
printf("%c",storage[0][i]);
}
while(storage[x][y]!=0){
printf("%c",storage[0][y]);
y++;
}
}
I'd like to ask for some help on how do I make the while loop work. It doesn't give me any errors when compiling its just the value on while loop doesn't show up. only the other printf
s before that.