ulfben icon

Basic printf-a-like

ulfben | PRO | 01/05/19 04:23:22 PM UTC | 0 ⭐ | 840 👁️ | Never ⏰ | []
C++ |

630 B

|

None

|

0 👍

/

0 👎

#include <iostream>
namespace utils{
    void printf(const char* format){
        std::cout << format;
    }
    template<typename T, typename ... Args>
    void printf(const char* format, T value, Args ... args){
        for ( ; *format != '\0'; format++ ) { 
            if ( *format == '%' ) {
               std::cout << value;
               printf(format + 1, args ... );
               return;
            }
            std::cout << *format;
        }
    }
    template<typename T, typename ... Args>
    void printf(const std::string& format, T value, Args ... args){
        printf(format.c_str(), value, args...);
    }
}
 
int main(){ 
    utils::printf('% world% %\n', "Hello", '!', 2019);                            
}

Comments

  • Gyqizv icon
    04/02/26 06:22:06 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
     Remove the @ 
  • Yuizcko icon
    05/18/26 01:06:10 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400