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

  • Home
  • SEARCH
  • 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 9235519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:03:48+00:00 2026-06-18T07:03:48+00:00

I haven’t learned pointers yet, so I have no idea what other answers were

  • 0

I haven’t learned pointers yet, so I have no idea what other answers were talking about when someone was asking the same question :S…

while(1)
{
    /* intializing variables for the while loop */
    temp1 = 0;
    temp2 = 0;
    val = 0;
    for(counter = 0; counter < 256; counter++)
    {
        input[counter] = ' ';
    }

    scanf("%s", &input);                                            /* gets user input */

    if(input[0] == 'p')                                             /* if user inputs p; program pops the first top element of stack and terminates the loop */
    {                                                               /* and the program overall                                                               */
        printf("%d", pop(stack));
        break;
    }
    if(input[0] == '+' || input[0] == '-' || input[0] == '*')       /* if operator is inputted; it pops 2 values and does the arithemetic process */
    {
        if(stackCounter == 1 || stackCounter == 0)                  /* If user tries to process operator when there are no elements in stack, gives error and terminates */
        {
            printf("%s", "Error! : Not enough elements in stack!");
            break;
        }
        else
        {
            temp1 = pop(stack);
            temp2 = pop(stack);

            push(stack, arithmetic(temp2, temp1, input[0]));
        }
    }
    else                                                            /* if none of the above, it stores the input value into the stack*/
    {
        val = atoi(input);                                          /* atoi is used to change string to integer */
        push(stack, val);
    }
}

it’s a program for doing the same operation as postfix with finite a stack. The other functions are all working ok. When I compile and run on Visual Studio, it works fine, but when I run it on linux (which is used to test my program), it doesn’t work. It just gives me: “c:52: warning: char format, different type arg (arg 2)”.

I am assuming its the scanf or the atoi function that is causing the problem…

Is there any way to fix this program easily by just changing few letters?

  • 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-18T07:03:52+00:00Added an answer on June 18, 2026 at 7:03 am

    You should not use ampersand (&) when reading a character array. Change: scanf("%s", &input); to scanf("%s", input); and all should be fine.

    input is already a pointer to the begining of the block of memory where the character array will be stored, no need to take its address.

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

Sidebar

Related Questions

Haven't seen many Geneva related questions yet, I have posted this question in the
I haven't used ARC yet other than to deal with it when it forces
Haven't found a working solution as of yet. I have three different versions of
Haven't been able to figure this out yet.. I've seen a few answers around
This could be a duplicate question, but I have no idea what search terms
Haven't seen this before so hopefully someone has a easy solve, I have a
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I haven't tried that yet, but I assume that I would have to disable
Haven't found a solution to this problem yet, have tried some things... I have
Haven't seen anything about it here but it seems to solve one of the

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.