fork download
  1. #include <iostream>
  2.  
  3. template<typename T, typename... Args>
  4. void printf(const char *s, T value, Args... args)
  5. {
  6. while (*s) {
  7. if (*s == '%') {
  8. if (*(s + 1) == '%') {
  9. ++s;
  10. }
  11. else {
  12. std::cout << value;
  13. printf(s + 1, args...); // call even when *s == 0 to detect extra arguments
  14. return;
  15. }
  16. }
  17. std::cout << *s++;
  18. }
  19. }
  20.  
  21. int main() {
  22. printf("test % %", "String", 10);
  23. return 0;
  24. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
test String 10