include <iostream>
#include <iomanip>
#include <stdarg.h>
void stl_printf(const char* s)
{
while (*s)
{
std::cout << *s++;
}
}
template<typename TValue, typename...TArgs>
void stl_printf(const char* s, TValue value, TArgs... args)
{
while (*s)
{
if (*s == '%' && (*++s) != '%')
{
std::cout<<value;
stl_printf(*s ? ++s : s, args...);
return;
}
std::cout<<*s++;
}
}
void c_printf(char c, va_list& args)
{
switch (c)
{
case 'd':
std::cout << va_arg(args, int);
break;
case 'c':
std::cout << va_arg(args, char);
break;
case 'f':
std::cout<<std::fixed<< va_arg(args, double);
break;
case 's':
std::cout << va_arg(args, char*);
break;
}
}
void c_printf(const char* s, ...)
{
va_list args;
va_start(args, s);
while (*s)
{
if (*s == '%' && *(++s) != '%')
{
c_printf(*s++, args);
}
else
{
std::cout << *s++;
}
}
va_end(args);
}
int main(int argc, char* argv[])
{
stl_printf("hello %s_%d_%f", "vison0300", 123, 0.123);
c_printf("hello %s_%d_%f", "vison0300", 123, 0.123);
char c;
std::cin >> c;
return 0;
}