this is a function i am trying to write so that i can set up a vector for a flag operation to make sure i don't process the same letter of a string twice. i do understand variables(well i thought i did) from what i know if a variable is declared at the begginning of the function, then it should be available throughout the entire function right? could someone please look at my code and tell me where i am going wrong please? I could use another global vector but as i read everywhere, its best to keep globals to a minimum!

Thanks for your time!

Werdy666

Code:
#include <vector>

using namespace std;

extern vector <string> words;

int init()
{
string temp;

vector <int> flag; // *****i want this local to this function

// if i put flag.pushback(0) here this works fine!

ifstream load;
load.open(NAMES);
if (load.fail())
	{
	cout << endl << "Error! Cannot load word file! Please reinstall!" << endl;
	exit(0);
	}
while (!load.eof())
	{
	std::getline(load,temp);
	words.push_back(temp);
	cout << endl << temp;
	}

int test;
string jumbled;
	
cout << endl << int(words.size()) << endl;
cout << int(words[5].length()) << endl;

cout << "lets try to jumble a word at random" << endl;
cout << "You see the list.... Pick one! ";

cin >> test ;
int lengthofstring = int(words[test].length());

for (int fil = 0; fil < lengthofstring ; fil++)
	{
                flag.pushback(0) ; //*** this is the line where it doesn't recognise 'flag' as a vector
	}
	
	for (int loop = 0 ; loop < lengthofstring ; loop++)
		{
		
		}
	

return 0;
}