register_printf_function / Visual C++

Started by
2 comments, last by Krylloan 20 years, 6 months ago
Does the function register_printf_function() (Or an equivalent function) exist in Visual C? I''m using a custom string type (int len, char *chars), and I want to be able to print this using printf, something similar to "%s". Here''s the page that I got from googling on custom format specifications: http://www.gnu.org/manual/glibc-2.2.5/html_node/Registering-New-Conversions.html#Registering%20New%20Conversions It says register_printf_function is ISO C (Is this similar to ANSI C?), but MSDN seems not to know about it.
Advertisement
Would vprintf (or any variant of it) be ok ?

MSVC has it as _vprintf.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote:It says register_printf_function is ISO C (Is this similar to ANSI C?), but MSDN seems not to know about it.

Er no it doesn''t.

It says the opposite:
Portability Note: The ability to extend the syntax of printf template strings is a GNU extension. ISO standard C has nothing similar.

char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
Anyway, the answer is, no, it doesn''t. You''ll have to write your own printf from scratch. This is another reason why C is rather lacking.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/

This topic is closed to new replies.

Advertisement