"Printf" function in MFC

Source: Internet
Author: User

I still read the C language. I can't use the C language printf function in MFC, so:

Int mfcprintf (const char * m_data ,...)
{
Cstring STR;
Char printf_buf [1024];
Va_list ARGs;
/*
ARGs is a variable defined to point to variable parameters. va_list and the va_start and va_end variables to be used are all defined in
Macros must be used in variable parameter functions, which are defined in the stdarg. h header file.
*/
Int printed;

Va_start (ARGs, m_data); // initialize the ARGs function to point to the first parameter of a Variable Parameter. FMT is the first parameter of a variable parameter.
// A PARAMETER
Printed = vsprintf (printf_buf, m_data, argS );
Va_end (ARGs); // obtain the variable end Parameter

STR = printf_buf;
Int ncount = m_print.getlinecount (); // obtain the number of rows, including the return row
Int nlastline = m_print.lineindex (ncount-1); // obtain the number of characters. Multiple lines are allowed.
M_print.setsel (nlastline + 1, nlastline + 2); // set the area selected by the cursor
M_print.replacesel (STR); // text replacement
Return printed;
}

"Printf" function in MFC

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.