void Display(char* word)
{
static char* pointerToWord = word;
cout << pointerToWord;
}
void initialise(char* word)
{
Display(word);
}
void main()
{
char* word[3];
char* currentWord;
word[0] = "Hello";
word[1] = "World";
word[2] = "hahahaha";
currentWord = word[0];
initialise(currentWord);
currentWord = word[1];
//Displays word[0]
Display(0);
currentWord = word[2];
//Still Displays word[0]
Display(0);
}
Char* were always a bit of a pain in the neck. Can you help me get syntax right?
All I want is
initialise()
Display()
's pointer to a current worduse
Display()
to display wherever the pointer is pointing toIn reality I've got a few classes involved, but this example pretty much illustrates the problem. Also I have no intention of modifying the string, so the strings are constant.