In C++, I need a macro that builds a string that includes the file and the line number..

C++, Linux

as part of my effort to understand an application I have, I need to build a macro that automatically builds a string with the file number and the line number.
I can print that string that will show me the execution path.
I am going to add this Macro in places and print the output!
Who is Participating?
sunnycoderConnect With a Mentor Commented:
The format specifiers work only with printf family of functions ... to for a string, use sprintf

sprintf (mystring, "%s %s %d\n",__FILE__,__FUNCTION__,__LINE__);

Note ... snprintf is safer than printf .. make sure mystring has sufficient memory
__LINE__, __FUNCTION__, __FILE__

#define LOG_HERE printf("%s %s %d\n",__FILE__,__FUNCTION__,__LINE__)
EmadGirgisAuthor Commented:
Thank you very much...
I need to advance this so it would generate me a string to pass to other function!!

So I mean
string S
S would be equal to
("%s %s %d\n",__FILE__,__FUNCTION__,__LINE__)
All Courses

From novice to tech pro — start learning today.