Use VC to convert a TXT file into an HTM file

Source: Internet
Author: User
When we are working on the homepage, we sometimes need to convert the TXT file into an HTM file. In fact, we can write a small ProgramTo convert the TXT file into an HTM file. Here, we use VC to write this program. First, create a new dialog box program, and then add two text boxes and one button in the dialog box, use classwizard to connect two text boxes with two variables. These two variables are in the cstring class. One variable is m_txt, indicating the path and file name of the TXT file to be converted, and the other is m_htm, which is used to store the path and file name of the converted HTM file.

Then add the button control and clickCodeAs follows:

Updatedatatrue
Cstdiofile srcfile
Srcfile. openm_txtcfilemoderead
// Put the contents of the TXT file to be converted into the strtemp variable through the cstdiofile class
Cstring strtemp
Srcfile. readstringstrtemp
Srcfile. Close
Cstdiofile FF
Ff. openm_htmcfilemodecreate | cfilemodereadwrite
Ff. writestring ″″
// Put the strtemp content in the file pointed out by the m_htm variable, add the HTM file header, and the file name must be
// End with htm
Ff. writestringstrtemp
Ff. writestring ″″
Ff. Close
Afxmessagebox "converted successfully ″

This program is successfully debugged in window2000 and vc6.0.

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.