473,465 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

infix to postfix notation

momotaro
357 Contributor
this is my code:
Expand|Select|Wrap|Line Numbers
  1.  void ConvertToPostFix(char *exp) 
  2.  
  3. {
  4.  
  5. int i;
  6.  
  7. stack *s;
  8.  
  9. StackEntry *item;
  10.  
  11. s = CreatStack(&s);
  12.  
  13. for(i = 0; i != '\n'; i++)
  14.  
  15. {
  16.  
  17. if(isalnum(exp[i]))
  18.  
  19. printf("%c", exp[i]);
  20.  
  21. else if(StackEmpty(s))
  22.  
  23. Push(exp[i], s);
  24.  
  25. else
  26.  
  27. {
  28.  
  29. while(check(exp[i], s->entry[s->top]))
  30.  
  31. Pop(item, s);
  32.  
  33. if(check(exp[i], s->entry[s->top]))
  34.  
  35. Push(exp[i], s);
  36.  
  37. }
  38.  
  39. }
  40.  
  41. }
  42.  
  43.  
the error message is :
[size=1]main.obj : error LNK2019: unresolved external symbol _check referenced in function _ConvertToPostFix

and:
[size=1]fatal error LNK1120: 1 unresolved externals

in addition to some WARNINGS that i realy danot know how to avoid them...

WARNINGS:
1: warning C4047: 'function' : 'int *' differs in levels of indirection from 'int **__w64 ' main.c 18


2: warning C4024: 'DisplayMenu' : different types for formal and actual parameter 1 c:\main.c 18

3: warning C4047: 'function' : 'int *' differs in levels of indirection from 'int **__w64 ' main.c 19

4: warning C4024: 'DoCommand' : different types for formal and actual parameter 1 cmain.c 19

5: warning C4047: 'function' : 'stack *' differs in levels of indirection from 'stack **__w64 ' main.c 58

6: main.c(58) : warning C4024: 'CreatStack' : different types for formal and actual parameter 1

7: main.c(68) : warning C4700: uninitialized local variable 'item' used
Oct 28 '07 #1
4 2866
tracethepath
15 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. for(i = 0; i != '\n'; i++)
  3.  
  4.  
basic problem i think is i cant be compared to a character type...
i is an integer
what you should do is

Expand|Select|Wrap|Line Numbers
  1. for(int i=0; exp[i]!='\0'; i++)
  2.  
Oct 28 '07 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
i can be compared to an integer because it is an integer.

Read up on arithmetic conversions an you will see that in expressions the first thing the compiler does is convert all char and short to int. Additional rules proceed form there.

I am more interetd in the fact that check function can't be found. Maybe that could be posted. That's what's causing the LNK2019.

All of the warnings are avoidable. You never allow warnings in your code. Often before a release, the compiler is set to convert all warnings to errors.
Oct 28 '07 #3
momotaro
357 Contributor
this is my all new peace of code but am still havin unexpecetd result:

input: 1+2-3/4 normal output: 12+34/- code result: 12+34/1+2-3/4

this is my code:
Expand|Select|Wrap|Line Numbers
  1. void ConvertToPostFix(char *exp)
  2.  
  3. {
  4.  
  5. int i;
  6.  
  7. stack *s;
  8.  
  9. StackEntry *item;
  10.  
  11. s = CreatStack(&s);
  12.  
  13. for(i = 0; exp[i] != '\0'; i++)
  14.  
  15. {
  16.  
  17. if(isalnum(exp[i]))
  18.  
  19. printf("%c", exp[i]);
  20.  
  21. else if(StackEmpty(s))
  22.  
  23. Push(exp[i], s);
  24.  
  25. else
  26.  
  27. {
  28.  
  29. while(check(exp[i], s->entry[s->top]) && !StackEmpty(s))
  30.  
  31. {
  32.  
  33. Pop(&item, s);
  34.  
  35. printf("%c", item);
  36.  
  37. }
  38.  
  39. if(!check(exp[i], s->entry[s->top]))
  40.  
  41. Push(exp[i], s);
  42.  
  43. }
  44.  
  45. }
  46.  
  47. }
  48.  
  49.  
Oct 28 '07 #4
momotaro
357 Contributor
I think that the problem first is that this line of code id not executed:
Expand|Select|Wrap|Line Numbers
  1.  if(!check(exp[i], s->entry[s->top])) 
  2. Push(exp[i], s);
  3.  
  4.  
Oct 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: KidLogik | last post by:
Hello! I am converting an infix expression string into a postfix so that I will be able to evaluate it easier -> (5*(((9+8)*(4*6))+7)) == 598+46**7+* I believe the rule is "Replace all...
22
by: Tony Johansson | last post by:
Hello Experts! I'm reading i a book about C++ and they mention infix with telling what it is. I hope you out there can do so. Many thanks! //Tony
19
by: caramel | last post by:
i've been working on this program forever! now i'm stuck and going insane because i keep getting a syntax error msg and i just can't see what the compiler is signaling to! #include <stdio.h>...
6
by: PIEBALD | last post by:
Anyone got an infix to postfix (RPN) math notation converter? I've looked around a bit and haven't found anything quite what I want. I just want a method that will take a string in infix notation...
30
by: Xah Lee | last post by:
The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations Xah Lee, 2006-03-15 In LISP languages, they use a notation like “(+ 1 2)” to mean “1+2”....
0
by: coolguyjas07 | last post by:
plzzzzzz help me out to run my source code ......... i hav written dis code to convert infix expression to postfix but not getting desired output.... plzzz help me to get correct output.. d source...
3
by: jackikay | last post by:
how do i write a program that converts infix to postfix.?
6
by: jimmuel001 | last post by:
pls help me fo my assignment that will allow the user to input infinite equations in infix type. and will output in postfix. thanks!
1
by: aitia | last post by:
this the code. i used ECLIPSE to run this.. it has some codes smells that i can't seem to figure out.. can any one help? import java.io.*; import java.util.*; public class Postfix { private...
2
by: zeroeight | last post by:
Hi guys, I'm a newbie here, I just want to seek for help regarding my program. I want to implement an infix to postfix conversion only accepting numbers. Right now, I already debugged the errors...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.