-
No Console Output VS2008
I wrote this little code today in standard c++. It built in visual studio 2008, but the console window is not display the information. Why???
Code:
#include "stdafx.h"
#include <iostream>
using std::cerr;
using std::cout;
using std::cerr;
using std::endl;
int engalgomod(int number_of_genes, int & state);
int main(array<System::String ^> ^args)
{
// Console::WriteLine(L"Hello World");
int state = 0;
state = 1;
int error = 0;
do
{
error = engalgomod(5,state);
cerr << error << " loop control variable buffer overun finite resoure negative conotation error. Bogus!" << endl;
cout << "Genetic code: " << state << endl;
} while (error = -1); // the mod function never returns a negative number
return 0;
}
int engalgomod(int number_of_genes, int & state)
{
// state of egine correlates to gene
while (true)
{
state = state % number_of_genes + 1;//the entirity of the engine
}
int exception;
return exception;
}
I'm using an intel based quadcore i7 processor.
-
Because engalgomod() falls into an infinite loop with no way out...
Code:
while (true)
{
state = state % number_of_genes + 1;//the entirity of the engine
}
-
I don't know a solution. The function engalgomod has parameter state that is a reference variable. I know pre current standard C++ cout is not "threadsafe", but what "thread safe" means; I don't remember. I did test with a conditional so I think your correct, because cout displayed 5. To fix the problem I'm guessing I need to multit thread the 0 the function from the primary primay thread. This is good because the thread uses cout and a shared variable that is not locked (ie not thread safe). In regard to the semantics which solution suggest that is simples, 1) conditional reuturn or 2) multi threading or 3)erroneous develepor interpation of the solution? The intention of the engine is to count 1, 2, 3, 4, 5 1, 2, 3, etc ad infinitum??
-
This is not standard C++. This is C++/CLI or Managed C++. You have selected an incorrect project. Select a console application or Windows application and nothing else.