Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdarg.h>
  4. #include <wchar.h>
  5.  
  6. #define printf(format, args...) wprintf (L##format, ##args)
  7. #define _add_l(format) (L##format)
  8.  
  9. typedef void* handle_type;
  10. typedef handle_type(*open_func)(const char*, const char*);
  11. typedef int(*printf_func)(handle_type, const char*, ...);
  12. typedef int(*wprintf_func)(handle_type, const wchar_t*, ...);
  13. wprintf_func Printf;
  14.  
  15. int
  16. roprintf(const wchar_t *format, ...)
  17. {
  18. int ret;
  19. va_list ap;
  20.  
  21. va_start(ap, format);
  22. ret = vfwprintf(stdout, _add_l(format), ap);
  23. va_end(ap);
  24. return (ret);
  25. }
  26.  
  27. int main(int argc, char *argv[])
  28. {
  29. wchar_t *snafu = L"notação";
  30. char *foo = "foo";
  31. Printf = (wprintf_func)&roprintf;
  32.  
  33. // Printf should do the same as printf
  34. printf("%ls\n",snafu);
  35. Printf("%ls\n",snafu);
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement