emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

C standard library C

Ein C-Snippet für C standard library, das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

C standard library C

Datei
writegif.c
Ausführen
cc -o writegif writegif.c && ./writegif
#include <stdio.h>

static const unsigned char gif[] = {0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b};

int main(void) {
    FILE *f = fopen("pixel.gif", "wb");
    if (!f) return 1;
    size_t n = fwrite(gif, 1, sizeof gif, f);
    return fclose(f) != 0 || n != sizeof gif;
}

Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.

Offizielle Website: C standard library

Mehr in C