Hello.

I'm currently using the book "The C programming Language" as my top tool to understand the programming patterns of the C language.

In chapter 4 they were structuring functions and I've managed to split successfully some other programs declaring prototype functions in headers as well as defining them in their correspondent source code. However, by using the debugger "gdb 7.12" I've found the next odd behaviour.

Code:
#include "getch.h"

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


#define SIZE 10


int getint(int *pn){
    int character;
    int sign;
    int second_character;

    while (isspace(character = getch())) // call to getch()
        ;
...
Code:
#include <stdio.h>


#define BUFSIZE 100


char buf[BUFSIZE];

// Supposedly, this global initialization should assign 0 to all bufp variables
int bufp = 0;


void ungetch(int character){
    if (bufp >= BUFSIZE)
        printf("Existen muchos caracteres\n");
    else
        buf[bufp++] = character;
}


// Entry point of getch() call
int getch(void){
    // It never executed the statement int bufp = 0 according to dbg
    return (bufp > 0) ? buf[--bufp] : getchar();
}
As I have stated, I'm stuck in explaining why the compiler "gcc 6.3.0" does not execute the statement that assign bufp before returning the values in the getch function. Also, I have compiled using both c99 and c89 standards discarding any incompatibilities in that matter.

Any help will be greatly appreciated.