Since the CRT Runtime Library cannot be called after the entry is changed
The image is output.
A better way is to use dialog and edit box.
# Include <windows. h>
# Include <iostream>
Using namespace STD;
# Pragma comment (linker, "/subsystem: Windows ")
# Pragma comment (linker, "/entry: Main ")
Int main ();
Void entrypoint ()
{
Main ();
}
# Define safe_delapiheap (m_hdl, p) {If (p )! = NULL) {heapfree (m_hdl), 0, (void *) (p ));}}
Char * g_szbuf = NULL;
Int g_bufsize = 260;
Const int g_guilines = 50;
Void getstrtext (handle param_hdl, char * sztext)
{
Int size = lstrlen (sztext );
G_bufsize = g_bufsize + size;
Char * Buf = NULL;
Buf = (char *) heapalloc (param_hdl, 0, g_bufsize );
If (BUF! = NULL)
{
Lstrcpy (BUF, g_szbuf );
Lstrcat (BUF, sztext );
// Response» '{}}% ********************************
Safe_delapiheap (param_hdl, g_szbuf );
G_szbuf = (char *) heapalloc (param_hdl, 0, g_bufsize );
If (g_szbuf! = NULL ){
Lstrcpy (g_szbuf, Buf );
}
}
// É ¾ ³ ý áù ± ¿õ ¼ ä
Safe_delapiheap (param_hdl, Buf );
}
Int main ()
{
Handle HDL = getprocessheap ();
G_szbuf = (char *) heapalloc (HDL, 0, g_bufsize );
Lstrcpy (g_szbuf ,"");
Getstrtext (HDL, "Hello World ");
Getstrtext (HDL, "IBM \ n ");
Getstrtext (HDL, "thank you all the same \ n ");
For (INT I = 0; I <g_guilines; ++ I ){
Char tmpbuf [260] = {0 };
Wsprintf (tmpbuf, "% s \ n", "Hello World ");
Getstrtext (HDL, tmpbuf );
}
MessageBox (null, g_szbuf, 0, 0 );
Safe_delapiheap (HDL, g_szbuf );
Return 0;
}