Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

Creating a Linked List of Char

OpenStudy (anonymous):

i have a program that computes a stack in linked list for numbers, and i was wondering if it could be done the same for characters.

OpenStudy (anonymous):

@wio

OpenStudy (anonymous):

for numbers? what do you mean?

OpenStudy (anonymous):

nvm, i got that one, but i'm stuck with another one. i am trying to convert Infix expression in to Postfix expression but my code is not changing it, can you see the code and see what i did wrong?

OpenStudy (anonymous):

I don't know what you are trying to do or what language you are using.

OpenStudy (anonymous):

im using C++, and tying to convert Infix Expression to Postfix expression

OpenStudy (anonymous):

operation overriding?

OpenStudy (anonymous):

yes

OpenStudy (anonymous):

You put (int) as an argument and don't use it, that will change it to postfix.

OpenStudy (anonymous):

can you clarify it more? also i can't use libraries

OpenStudy (anonymous):

In order to change the function signature so it overloads postfix instead of prefix, you need to have to give it an int parameter.

OpenStudy (anonymous):

sorry, but what did you mean by operation overriding?

OpenStudy (anonymous):

Making it so that you can use operations like +, ++, -, etc. on objects of a class that has defined their behavior.

OpenStudy (anonymous):

the struct is for the stack

OpenStudy (anonymous):

What is the problem?

OpenStudy (anonymous):

it doesn't crash or anything, it runs so basically, the program asks the user to input "Infix expression", and it is suppose to convert it to "postfix", but it doesn't convert it; it gives me back the "Infix expression" instead of the "postfix"

OpenStudy (anonymous):

what are examples of input?

OpenStudy (anonymous):

Your code doesn't even compile.

OpenStudy (anonymous):

it can be anytype of expressions like for example: 5+9/5-1*23 something like that

OpenStudy (anonymous):

it should, hold on let me check it again

OpenStudy (anonymous):

also, you didn't even indent it properly.

OpenStudy (anonymous):

take out the return value on "void pop" and it should compile

OpenStudy (anonymous):

will it have an effect on the code for not being indented properly?

OpenStudy (anonymous):

No, when it isn't indented properly, my willingness to help shrinks considerably.

OpenStudy (anonymous):

Why should this code even work?

OpenStudy (anonymous):

when i paste it to notepad, the lines went out of control

OpenStudy (anonymous):

Code has no comments and is hard to read. I have no idea what it is supposed to actually be doing. What do you expect the output to be?

OpenStudy (anonymous):

It's okay, i'll try to fix it up tomorrow. Thanks for your time

OpenStudy (anonymous):

Here is what you need to do. Create a function which prints our what is in your stack. Then print out your stack after each loop.

OpenStudy (anonymous):

okay

OpenStudy (anonymous):

Good news is that your stack is working at the very least. Bad news is it is always empty in your code.

OpenStudy (anonymous):

I moved the ``` while (!empty()){ convertpost += topy(); pop(); } ``` To be outside of the for loop, and got `59+5/1-23*` for output

OpenStudy (anonymous):

``` int highpress (char a){ int worth = -1; switch (a){ case '+': case '-': worth = 1; break; case '*': case '/': worth = 2; break; case '(': case ')': worth = 3; break; case '$': worth = 4; } return worth; } ``` Putting break statements in your switch statement got output of `595/+123*-`

OpenStudy (anonymous):

moving the the "while"outside the "for loop" worked :) Thanks a lot

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!