Checking the return values

Posts 1–5 of 5 · Page 1 of 1
Checking the return values
How can I check the return value of a function and then send it into another function.

Code:
#include "global.h"

ISpVoice * mainVoice = NULL;

int main()
{
	CoInitialize(NULL);
    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&mainVoice);
    if( SUCCEEDED( hr ) )
    {
	//Start Essential Processes
    hr = mainVoice->Speak(L"Start Up. Initiated.", 0, NULL);
	Boot_Up();
	//Choose User-Mode
	hr = mainVoice->Speak(L"Selecting User Mode.",0, NULL);
	User_Mode();
	//Start the Main Loop
	hr = mainVoice->Speak(L"Entering Main Loop.",0, NULL);
	M_Dogma(User_Mode());
	//Clean Up and Shutdown
	    mainVoice->Release();
        mainVoice = NULL;
    }
    CoUninitialize();
	Shutdown(M_Dogma(User_Mode()));

	return COMPLETE;
}
I want to send the return value of User_Mode() into M_Dogma(). Then I want to send the return value of M_Dogma() into Shutdown().
Learn C++ first? >.>
Lol yeah you should spend 10 minutes reading the first few pages of a C++ tutorial.

Code:
Shutdown(M_Dogma(User_Mode()));

bool M_Dogma(int val)
{
if (val > 5)
return true;
else
return false;

User_Mode()
{
return rand() % 10;
}

void Shutdown(bool force)
{
ExitWindowsEx(force ? EWX_SHUTDOWN | EWX_FORCE : EWX_SHUTDOWN);
}
Quote Originally Posted by freedompeace View Post
Lol yeah you should spend 10 minutes reading the first few pages of a C++ tutorial.

Code:
Shutdown(M_Dogma(User_Mode()));

bool M_Dogma(int val)
{
if (val > 5)
return true;
else
return false;

User_Mode()
{
return rand() % 10;
}

void Shutdown(bool force)
{
ExitWindowsEx(force ? EWX_SHUTDOWN | EWX_FORCE : EWX_SHUTDOWN);
}
I actually did it differently.
Code:
#include "global.h"

ISpVoice * mainVoice = NULL;



int main()
{
int mode;
int shutdownmode;
	CoInitialize(NULL);
    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&mainVoice);
    if( SUCCEEDED( hr ) )
    {
	//Start Essential Processes
    hr = mainVoice->Speak(L"Start Up. Initiated.", 0, NULL);
	Boot_Up();
	//Choose User-Mode
	hr = mainVoice->Speak(L"Selecting User Mode.",0, NULL);
	mode = User_Mode();
	//Start the Main Loop
	hr = mainVoice->Speak(L"Entering Main Loop.",0, NULL);
	shutdownmode = M_Dogma(mode);
	hr = mainVoice->Speak(L"Cleaning Up.",0, NULL);
	//Clean Up and Shutdown
	    mainVoice->Release();
        mainVoice = NULL;
    }
    CoUninitialize();
	Shutdown(shutdownmode);

	return COMPLETE;
}
Quote Originally Posted by aanthonyz View Post
I actually did it differently.
Code:
#include "global.h"

ISpVoice * mainVoice = NULL;



int main()
{
int mode;
int shutdownmode;
	CoInitialize(NULL);
    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&mainVoice);
    if( SUCCEEDED( hr ) )
    {
	//Start Essential Processes
    hr = mainVoice->Speak(L"Start Up. Initiated.", 0, NULL);
	Boot_Up();
	//Choose User-Mode
	hr = mainVoice->Speak(L"Selecting User Mode.",0, NULL);
	mode = User_Mode();
	//Start the Main Loop
	hr = mainVoice->Speak(L"Entering Main Loop.",0, NULL);
	shutdownmode = M_Dogma(mode);
	hr = mainVoice->Speak(L"Cleaning Up.",0, NULL);
	//Clean Up and Shutdown
	    mainVoice->Release();
        mainVoice = NULL;
    }
    CoUninitialize();
	Shutdown(shutdownmode);

	return COMPLETE;
}
Ugh, I just merely provided an example of how you wanted it - using the return value of a function as the parameter of another...
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us