could someone explain to me why the compiler(gcc) outputs a warning that the
control reaches the end of a non void function?
#include <stdio.h>
#include "stack.h"
#include "globals.h"
#include "stack_interface.h"
#define ERR_PUSH "Error in pushing symbol (character #%d).\n"
#define ERR_POP "Error in popping symbol tp match character #%d.\n"
#define ERR_MATCH \
"Incorrect closing symbol '%c' (character #%d). Expecting '%c' .\n"
#define ERR_EOL "Unexpected end of input line. Expecting:\n\t"
char matching_symbol(char c);
int main(int argc , char *argv[]){
char c, *ptr, buffer[BUFSIZ] ;
bool error ;
stack S ;
init_stack(&S) ;
printf("? ") ;
while(gets(buffer) != NULL && buffer[0] != '\0') {
error = FALSE ;
for(ptr = buffer ; *ptr != '\0' && error == FALSE ; ptr++) {
switch(*ptr){
case '(':
case '{':
case '[':
if(push_char(&S, *ptr) == ERROR ){
error = TRUE ;
printf(ERR_PUSH, ptr - buffer + 1) ;
}
break ;
case ')' :
case'}' :
case ']' :
if(pop_char(&S,&c ) == ERROR) {
error = TRUE ;
printf(ERR_POP , ptr - buffer + 1) ;
break ;
}
if (*ptr != matching_symbol(c)) {
error = TRUE ;
printf(ERR_MATCH , *ptr , ptr - buffer + 1 , matching_symbol(c));
}
break ;
}
}
if(error == TRUE)
while(empty_stack(&S) == FALSE)
pop_char(&S,&c) ;
else if (empty_stack(&S) == TRUE )
printf("Valid input.\n") ;
else{
printf(ERR_EOL) ;
while(empty_stack(&S) == FALSE) {
pop_char(&S,&c) ;
printf("%c" , matching_symbol(c)) ;
}
printf("\n") ;
}
printf("?") ;
}
}
char matching_symbol(char c)
{
switch (c) {
case '(' : return ')' ;
case ')' : return '(' ;
case '{' : return '}' ;
case '}' : return '{' ;
case '[' : return ']' ;
case ']' : return '[' ;
}
return 0;
}