Search code examples
cglibc

Duplicating a function with a new name


I am making a C library that creates a print function, which basically executes printf. Because of this, I wish to create a duplicate of printf from glibc, but with the name print. How can I duplicate this function without duplicating all of it's code?

(I found the code here but don't understand how to duplicate it in my library, or if it is legal to do so.)


Solution

  • There you go:

    #include <stdarg.h>
    
    void println(const char* format,...)
    {
        va_list args;
        va_start(args,format);
        vprintf(format,args);
        printf("\n");
        va_end(args);
    }