Could someone please tell me what these errors mean and how to fix them.

inputter.c: In function âget_next_tokenâ:
inputter.c:21: warning: initialization makes integer from pointer without a cast
inputter.c:17: warning: unused variable âcur_posâ
/* Get an RPN expression from the keyboard.
 * Accepts q as indictation that user wants to quit. 
 * Skips over invalid characters.
 * Normal end of expression is '='.  
 */

#include <stdio.h>
#include <ctype.h>
#include "inputter.h"

char *get_next_token(void)
{
    //return "123";
	int i = 0;
    char next_ch;
    static char input_buffer [1000] = {""};
    static int cur_pos = 0;
    printf ("Enter an RPN expression ending with =\n");
    fgets(input_buffer, 1000, stdin);
    return input_buffer;
	int length = input_buffer;
    //here
	do
    {
        next_ch = getchar();

        if (tolower((int)next_ch) == 'q')
        {
            // User wants to quit.
            input_buffer[0] = 'q';
            i++;
            break;
        }

        if ((next_ch == '\n') && (i > 0))
        {
            break;
        }

       if (isdigit(next_ch) ||
            (next_ch == '+') ||
            (next_ch == '-') ||
            (next_ch == '*') ||
            (next_ch == '/') ||
            (next_ch == '=')    )
        {
            input_buffer[i++] = next_ch;
        }

    } while ((input_buffer[i-1] != '=') && (i < length-1));
    //here
    input_buffer[i] = 0;     // Provide null terminator.

    while (next_ch != '\n')  // Clear keyboard input buffer
    {
        next_ch = getchar();
    }
}
/*
 * This function prompts the user to enter an RPN string
 * and reads the keyboard input into the buffer
 * specified by the caller.
 */

//void get_input(char* input_buffer, int length);

char *get_next_token(void);

these are warnings, not errors. meaning your program will compile and run (for a while), but probably will not work as expected because you're doing something unusual.

first one is you're assigning an int (length) to the char array (input_buffer).

before we can fix it, we've got to know what are you trying to do in the first place? are you trying to find the length of the string? then you need to use a function like "strlen()"

second one is just simply that you have a variable (cur_pos) that is not being used anywhere. the warning is in case you meant to use it but forgot. either delete it entirely or fix your code to use it.

another problem i see is the "return" statement in line 20. everything after that is meaningless because it will never get executed anyhow.

these are warnings, not errors. meaning your program will compile and run (for a while), but probably will not work as expected because you're doing something unusual.

first one is you're assigning an int (length) to the char array (input_buffer).

before we can fix it, we've got to know what are you trying to do in the first place? are you trying to find the length of the string? then you need to use a function like "strlen()"

second one is just simply that you have a variable (cur_pos) that is not being used anywhere. the warning is in case you meant to use it but forgot. either delete it entirely or fix your code to use it.

another problem i see is the "return" statement in line 20. everything after that is meaningless because it will never get executed anyhow.

Wow thats just lovely on the "return" statement in line 20 part. My professor is the one that told me to put it there.

Wow thats just lovely on the "return" statement in line 20 part. My professor is the one that told me to put it there.

i would suggest that either you misunderstood your professor, or your professor misunderstood what you were doing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.