Q:

Print the current function name by using __func__ in C | C preprocessor programs

belongs to collection: C Preprocessors Programs

0

Print the current function name by using __func__ in C | C preprocessor programs

Macro: __func__

__func__ is the predefine macro, and it is used to get the name of the current function. This macro is added in C99.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Example:

#include <stdio.h>

//fun1
void fun1(void){
	printf("Called function is: %s\n",__func__);
}

//fun2
void fun2(void){
	printf("Called function is: %s\n",__func__);
}

//Main code
int main(){
	
	printf("Called function is: %s\n",__func__);
	//function callings
	printf("Now,calling the functions...\n");
	fun1();
	fun2();
	
	return 0;	
}

Output

    Called function is: main
    Now,calling the functions...
    Called function is: fun1
    Called function is: fun2

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
The #line directive Example in C | C preprocessor ... >>
<< The __LINE__ Macro Example in C | C preprocessor p...