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