Correct segmentation fault when asking for an invalid layer_index in layer_name function

And removed stdio.h include (which is more for C language than C++)