perror shows value of errno. Since no error actually occurred - errno is 0. This is what is being printed