You are outputting a variable which you are not assigning. You are assigning it to the local variable inside the function and not to the Global One which you are printing in the main.