C ++ prints the file name, row number, compilation Date and Time example, and file name line number

Source: Internet
Author: User

C ++ prints the file name, row number, compilation Date and Time example, and file name line number

/*************************************** **************************************** ** Copyright (C ), 1988-1999, drvivermonkey. co ., ltd. file name: Author: Driver Monkey Version: Mail: bookworepeng@hotmail.com Date: 4.04.04.02 Description: **************************************** **************************************** */# include <iostream> # include <sstream> # include <fstream> using namespace std; /* run this program using the console pauser or add your own getch, system ("pause") or input loop */int main (int argc, char ** argv) {cout <__line __< <endl; // print the row number cout <__file __< <endl; // print the FILE name cout <__date __< endl; // print the date cout <__time __< <endl; // print the TIME}


How does the C language print the file name of the current source file and the current row number of the source file?

Print file, function, row number
Printf ("file = % s, func = % s, line = % d \ n" ,__ FILE __,__ FUNCTION __,__ LINE __);

In Linux c program, how does one print the file name and row number of the current file?

Printf ("% s, % u" ,__ FILE __,__ LINE __);

Related Article

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.