#include
#include
#include
#include
#include
int main()
{
int file;
of
You need to leave room for an end of line character, '\0';
So make char buffer[19]; char buffer[20]; then also add buffer[19] = '\0'; - remember it's zero based counting. Then it shouldn't have the garbage data.
The reason is because printf doesn't know where the end is of the character array. So it keeps printing until it finds a '\0' in garbage memory.