Thread: How can I evaluate an expression with the operator only known as a characte

  1. #1
    Registered User
    Join Date
    Jan 2017

    How can I evaluate an expression with the operator only known as a characte

    I am writing a program that implements an rpn type calculator while getting the values for it from a file. I am trying to figure out how I can Evaluate an expression when the operator is retrieved from the file. Right now I have this..

    double rpn_eval(char * fileName, double x){
    double a,b,c;
    File *fd;
    fd = fopen(fileName);
    char * word;
    while (word = nextword(fd)){
    if (word >= '0' && word <= '9'){
     a = stack_pop();
     b = stack_pop();
     //I want to evalute b (word) a
    If you could also redirect me to some source material so I could read about it that would be greatly appreciated, Thanks!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Perhaps (ignoring all the syntax errors in your pseudo-code)
    if ( word == '+' ) {
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Help]Evaluate a Prefix Expression Using Queue
    By Ravagioli in forum C Programming
    Replies: 0
    Last Post: 02-12-2015, 03:43 AM
  2. Evaluate mathematical expression
    By Nyah Check in forum C Programming
    Replies: 12
    Last Post: 06-20-2012, 04:29 PM
  3. Replies: 17
    Last Post: 10-06-2008, 07:54 PM
  4. Help! Program to evaluate expression...
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 02-19-2002, 06:20 AM
  5. Evaluate postfix expression program
    By shad0w in forum C Programming
    Replies: 1
    Last Post: 12-23-2001, 04:40 PM

Tags for this Thread