How to add a specifier of a new format, say %k , which will print a specific user structure in a specific format?
%k
What I want to do: -
struct k { //members }s1; printf ("%k", s1);
This printf must print the structure in a certain way.
printf
Yes, it is possible (but not portable) with register_printf_function , see 12.13 Configuring fff printing from libc documentation for more details:
register_printf_function
The GNU C library allows you to define your own custom transform specifiers for printf pattern strings to teach printf smart ways to print important data structures of your program.
Here is an example of creating such a special format specifier for the MAC address.
Source: https://habr.com/ru/post/972423/More articles:Comprehensive Claims at JWT - jwtIs it possible to model complex claims (hierarchical / nested / etc.)? - .netPut comments inside a multi-line literal list - pythonHTTP 403 Responses When Using Python Scrapy - pythonDebugging SFINAE in gcc or clang - c ++Best way to create a shared object in C ++? - c ++Parse valid JSON with TJSONObject using Embarcadero sample code. Error with exception - jsonOdd syntax in API "String :: concat" - javaCalling the constructor of a potential child from the database in C ++ - c ++Inheritance of extension methods - inheritanceAll Articles