I've learned that using non-const variables in file namespace is bad practice (and of course I don't want to develop bad habits). However, I'm not sure how I'm supposed to pass my variables through to other functions without putting them in file namespace and I can't find any solid examples or explanations anywhere.
example:
When putting this into practice I'm getting several errors:
error C4700: uninitialized local variable 'isRunning' used
error C4700: uninitialized local variable 'difficulty' used
error C4700: uninitialized local variable 'score' used
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <conio.h>
#include "main.h"
int main()
{
int score, difficulty;
bool isRunning;
Setup(score, difficulty, isRunning);
while (isRunning = true)
{
}
return 0;
}
I'd guess that your setup function is being given copies of the variables score, difficulty, isRunning. Anything it does, it does with those copies. The originals in the function main are unchanged.