Use C language and C ++ to output data to TXT text respectively

Source: Internet
Author: User
Tags setf
C language implementation

# Include <stdio. h>

File * FPO;                       
File * FPT;

Int main (INT argc, char ** argv)
{
   FPO = fopen ("po.txt", "W + ");    
   FPT = fopen ("pt.txt", "W + ");    

    Fprintf (FPO, "% d \ t % d \ n", pt1.x, pt1.y ); 
    Fprintf (FPT, "% d \ t % d \ n", pt2.x, pt2.y );    // Note that if integer data is output as a floating point, the result is 0.

   Fclose (FPO );
   Fclose (FPT );

   

    Printf ("\ n Alt at the same time and right-click the button and press it to narrow down the matching result chart \ n"); // output data to the display terminal
   Fprintf (stderr, "Finding features in % s... \ n", img2_file );

}

/////////////////////////////////////

Implementation of C ++

# Include <iostream>
# Include <fstream>
Using namespace STD;

Int main (INT argc, char ** argv)
{
  Ofstream poi1, poi2;
 Poi1.open ("point_o.txt", IOS: Out | IOs: APP );
  Poi1.setf (IOs: fixed, IOS: floatfield );
  Poi1.setf (IOs: showpoint );

  Poi2.open ("point_t.txt", IOS: Out | IOs: APP );
  Poi2.setf (IOs: fixed, IOS: floatfield );
  Poi2.setf (IOs: showpoint );

 Poi1 <matches [I]. First. x<"\ T" <matches [I]. First. Y<Endl;
  Poi2 <matches [I]. Second. x <"\ t" <matches [I]. Second. Y <Endl;

 Poi1.close ();
 Poi2.close ();

   STD: cout <"Matches:" <matches. Size (); // output data to the display terminal

}

 

// If the C ++ output method is used to output data to the TXT file in the source file suffixed with C, the vs2008 compiler may report an error. The solution is to change the suffix to CPP, create a new project, and then use the C ++ output method, which is more convenient. If some illegal keywords are used in the C file, modify the definitions of these variables to avoid repeated definitions with the keywords of C ++.

Http://blog.sina.com.cn/s/blog_702eac8701013k5m.html

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.