Did you call scanf() at all before trying to call fgets() in this function?