The OCC platform goes to VS2015 the MFC program calls console failure resolution

Source: Internet
Author: User

Article turned from: 54944668

have been using VS2010 to compile the OCC, a few days ago to the VS2015 platform, finally took two days to reconfigure the time, but found that the console can not input output, initially did not care, but the back of the debugging is very inconvenient, decided to transfer the console back.

The first thought is that the program error, the introduction of different input and output stream functions, resulting in the flow can not be located, so in the header file to block the relevant

#include <iostream>, #include <fstream>, etc., but still no use.

Later try to create a new console inside the function:

1 voidCmylattice::makecomkernel ()2 {3 allocconsole ();4     Longct1=GetTickCount ();5*6*7*8     LongCt2=gettickcount ();//System Run time (MS) after the end of the program segment9_cprintf ("bool Filter Time:", ct2-ct1);Ten freeconsole (); One}

But too much trouble, and the input is more inconvenient!

Finally consider may be vs2015 version problem, find a CSDN blog, encounter the same problem, the solution is as follows:

the first build function is as follows: BOOL cliu_occapp::initinstance () {.
.
. //redirection of standard output to console intHcrt,hin; BOOL Rep; FILE *hf,*Hi; _system_info LPs; GetSystemInfo (&LPs); Rep=AllocConsole (); HCRT=_open_osfhandle (intptr_t) GetStdHandle (std_output_handle), _o_text); HIn=_open_osfhandle (intptr_t) GetStdHandle (std_input_handle), _o_text); HF= _fdopen (HCRT,"W" ); Hi= _fdopen (HIn,"r+t");//REDIRECT input output freopen_s (&PF, "conout$", "w", stdout);*stdout = *HF; *stdin = *Hi; . . .}

Switch

BOOL cliu_occapp::initinstance () {    
.
.
. if (! AllocConsole () | | !freopen ("conout$""w", stdout)) AfxMessageBox (_t ("initconsolewindow failed! " // assign console to redirect output stream to console
     .
.
.
}

Can.

The OCC platform goes to VS2015 the MFC program calls console failure resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.