Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7975591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:41:08+00:00 2026-06-04T08:41:08+00:00

Ok. Let me start again. I am trying to write a program that would

  • 0

Ok. Let me start again. I am trying to write a program that would evaluate reverse Polish notation arguments to it. (i.e. ./program 2 4 +, which evaluates to 6).

int main(int argc, char *argv[]) 
{
   char oper[MAXOP];
   char *ptr;
   unsigned char c;
   double op2;
   while (--argc > 0 && ++argv != NULL) {
     ptr =  oper;
     if (isdigit(c = **argv)) 
     {
        while (isdigit(c = **argv++)) 
        {
            *ptr++ = c;
        }
        *ptr = '\0';
        push(atof(oper));
     } 
     else if (isalpha(c)) 
     {  
        while (isalpha(c = **argv++)) 
        {
            *ptr++ = c;
        }
                   ...
         ...
    }
}

The program should check the first character of each arguments if it is alpha or digit or an operator but it always turns out to be an alpha.

+++++++++ UPDATE +++++++++++++

Well, that’s odd. It is now working. Before the condition,
isdigit(c = **argv) wasn’t evaluating to true for numeric arguments (didn’t matter if the rest of the code was wrong). Now it does, but the condition isdigit(c = **argv++) is wrong.

It should be isdigit(c = *argv[0]++).

I had two files of the same name. They were in different directories but contain the same code. While working with this one, I must have been in the other directory and compiling the other file, and thus getting the same output despite edits to this one. My bad.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:41:09+00:00Added an answer on June 4, 2026 at 8:41 am

    Have you tried using a debugger and figuring out what happens?

    My first guess would be that **argv++ is wrong (are you increasing argv? *argv? **argv? Even if it’s not wrong, it’s just confusing code). Switch to:

    char *cur_arg = *argv;
    

    And go over cur_arg (using cur_arg++ to get to the next character, and not c=*cur_arg++ – again, confusing code).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me start by the end and the actual question: I'm trying to write
Let me start by telling you that I never used anything besides SVN and
Let me start out by saying that I'm not a C developer and I
Let me start by saying that this app was working fine the day before.
Let me start out by saying that I am new to Java/JSP web development,
let me start by saying that due to the complicated design of the layout
I'm trying to write code that will traverse an undirected, unweighted graph. Essentially, the
Let's see...where to start here? Okay, yes I am working in Joomla and trying
Let’s start with this statement: We have published couple of free applications on the
Let me start off by saying I don't want to print only the duplicate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.