ulfben

Basic printf-a-like

Jan 5th, 2019
931
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. namespace utils{
  3.     void printf(const char* format){
  4.         std::cout << format;
  5.     }
  6.     template<typename T, typename ... Args>
  7.     void printf(const char* format, T value, Args ... args){
  8.         for ( ; *format != '\0'; format++ ) {
  9.             if ( *format == '%' ) {
  10.                std::cout << value;
  11.                printf(format + 1, args ... );
  12.                return;
  13.             }
  14.             std::cout << *format;
  15.         }
  16.     }
  17.     template<typename T, typename ... Args>
  18.     void printf(const std::string& format, T value, Args ... args){
  19.         printf(format.c_str(), value, args...);
  20.     }
  21. }
  22.  
  23. int main(){
  24.     utils::printf('% world% %\n', "Hello", '!', 2019);                            
  25. }
Advertisement
Comments
  • Gyqizv
    217 days
    # text 0.21 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
    6.  
    7. Remove the @
  • Yuizcko
    171 days
    # text 0.19 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
Add Comment
Please, Sign In to add comment