the main() return statement is only reached by breaking the loop with an error, so return EXIT_FAILURE
put declarations in more appropriate scopes, and get rid of memset call