Dprintf() implementation


#1

Hey yall, I noticed that dprintf() was missing from the alpha release’s stdio library. Does beta now feature this function?

As a workaround, I am doing:

#include <stdarg.h>

int dprintf(int fd, const char *restrict format, ...) {
    va_list ap;
    FILE *f = fdopen(fd, "w");

    if (!f) {
        return -1;
    }

    va_start(ap, format);
    int result = fprintf(f, format, ap);
    va_end(ap);

    if (fclose(f) == EOF) {
        return EOF;
    }

    return result;
}

This seems to basically work, as basic as it is, so I thought I’d post it.

By the way, the Discuss WYSIWYG is acting strange about preformatted text–the last curly brace should be considered part of the code, but it is ending up as normal text for some reason.


#2

The WYSIWYM editor prefers triple-backslashes to “indent by one tab”, at least. Maybe that will help.

As I already replied to you on Reddit, we don’t implement dprintf yet as that ticket says. Why are you asking the same question here as there? I’ll give you the same answer…


#3

The WYSIWYG isn’t using triple backslashes correctly, then. I highlighed several lines and selected the code format button when I noticed that it wasn’t actually including the last line.


#4

I edited your message to fix the formatting (adding the triple backquote was enough)