those variables are local to main, your void function does not know them. if you need to keep no return type for this function and that those variables are not global( in this case) then pass them as parameters , by value in your case since your function needs to read them only.