No Console Output VS2008

This is a discussion on No Console Output VS2008 within the Windows Programming forums, part of the Platform Specific Boards category; I wrote this little code today in standard c++. It built in visual studio 2008, but the console window is ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    20

    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.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    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
    }

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    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??

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,455
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help editing console output
    By Longbow0705 in forum C++ Programming
    Replies: 6
    Last Post: 03-27-2009, 08:57 AM
  2. How to get the console output
    By outlawbt in forum Windows Programming
    Replies: 2
    Last Post: 03-19-2008, 02:25 PM
  3. Help with Console output
    By JeremyCAFE in forum C++ Programming
    Replies: 4
    Last Post: 12-20-2005, 09:36 AM
  4. Output to console window...
    By alvifarooq in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2004, 08:56 PM
  5. replacing console output
    By Lord CyKill in forum C Programming
    Replies: 1
    Last Post: 03-23-2003, 03:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21