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 827059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:30:51+00:00 2026-05-15T03:30:51+00:00

Trying to understand why this doesn’t work. I keep getting the following errors: left

  • 0

Trying to understand why this doesn’t work. I keep getting the following errors:
left of ‘->nextNode’ must point to class/struct/union/generic type
(Also all the lines with a -> in the function new_math_struct)

Header file

#ifndef MSTRUCT_H
#define MSTRUCT_H

    #define PLUS 0
    #define MINUS 1
    #define DIVIDE 2
    #define MULTIPLY 3
    #define NUMBER 4

    typedef struct math_struct
    {
        int type_of_value; 
        int value;
        int sum;
        int is_used;
        struct math_struct* nextNode;
    } ;

    typedef struct math_struct* math_struct_ptr;
#endif

C file

int get_input(math_struct_ptr* startNode)
{
    /* character, input by the user */ 
    char input_ch; 
    char* input_ptr;

    math_struct_ptr* ptr;
    math_struct_ptr* previousNode;

    input_ptr = &input_ch;
    previousNode = startNode;

    /* as long as input is not ok */ 
    while (1)
    {             
        input_ch = get_input_character();
        if (input_ch == ',') // Carrage return
            return 1;
        else if (input_ch == '.') // Illegal character
            return 0;


        if (input_ch == '+')
            ptr = new_math_struct(PLUS, 0);
        else if (input_ch == '-')
            ptr = new_math_struct(MINUS, 0);
        else if (input_ch == '/')
            ptr = new_math_struct(DIVIDE, 0);
        else if (input_ch == '*')
            ptr = new_math_struct(MULTIPLY, 0);
        else
            ptr = new_math_struct(NUMBER, atoi(input_ptr));

        if (startNode == NULL)
        {
            startNode = previousNode = ptr;
        }
        else
        {
            previousNode->nextNode = ptr;
            previousNode = ptr;
        }
    } 
    return 0;
}

math_struct_ptr* new_math_struct(int symbol, int value)
{
    math_struct_ptr* ptr;
    ptr = (math_struct_ptr*)malloc(sizeof(math_struct_ptr));
    ptr->type_of_value = symbol;
    ptr->value = value;
    ptr->sum = 0;
    ptr->is_used = 0;    
    return ptr;
}

char get_input_character()
{
    /* character, input by the user */ 
    char input_ch; 

    /* get the character */ 
    scanf("%c", &input_ch);     

    if (input_ch == '+' || input_ch == '-' || input_ch == '*' || input_ch == '/' || input_ch == ')')
        return input_ch; // A special character
    else if (input_ch == '\n')
        return ','; // A carrage return
    else if (input_ch < '0' || input_ch > '9')
        return '.'; // Not a number          
    else
        return input_ch; // Number
}

The header for the C file just contains a reference to the struct header and the definitions of the functions. Language C.

  • 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-05-15T03:30:51+00:00Added an answer on May 15, 2026 at 3:30 am

    Since your math_struct_ptr already contains the pointer declarator, you don’t need to specify it at the point of use. Drop the *:

    math_struct_ptr ptr;
    

    Or write

    struct math_struct *ptr;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to understand how class generics work and this bit just doesnt make
I am trying to understand why this program doesn't work Expected output: numbers 0-19
I'm trying to understand why this cast doesn't work: using System; using System.Collections.Generic; using
I'm trying to understand why this ajax called doesn't work $.ajax({ type: 'GET', url:
I'm trying to understand why this code doesn't work and the alert output is
I'm trying to understand why the following test does not fail. In this simplified
I am trying to understand an issue where event-listener registration on plugins doesn't work
I don't understand why this doesn't compile: struct A {}; template<class T> struct B
I don't understand why this doesn't work. I have a div with an iframe
I don't understand why this doesn't work. I am using a file to set

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.