Hey I was wondering if I could get some help. I just started to learn about pointers. And I seem to get it, i just cant seem to get why this code wont work. It does nothing useful I just wanted to see if I could create two function and make a third one using pointer so I could call both in this third function. This is what I came up with:
int color(int number) //For changing color of the console
color = GetStdHandle(STD_OUTPUT_HANDLE);
string shout(string sentence) //For saying a word
cout << sentence;
void all(string &refrence,int &number, string (*pointer)(string),int (*voidpointer)(int)) //To call both the color and shout function in one function
typecolor = (*voidpointer)(number);
phrase = (*pointer)(refrence);
int _tmain(int argc, _TCHAR* argv)
cout <<"Enter word > ";
int colorneed = 5;
My code does it jobs it says the word that the user entered and give it in the color purple. But then it crashes and gives me this error:
Debug Assertion Failed!
File: c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring
Expression: invalid null pointer
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
If I take out the string part and just keep the color function my all function can call upon it no problem. But adding the string part cause the error shown above to show. Is there something I must know about string pointers to make this work? Any help is appreciated.