Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

printf is too verbose and retarded of a name

Name: Anonymous 2021-03-09 11:00

Hey queers! Here is a proper replacement for printf called shit()

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>

void hidden_shit(uint64_t a0, ...) {
va_list ap;
uint64_t type = a0;
va_start(ap, a0);
type = va_arg(ap, uint64_t);
for (int i = 0; type; i++) {
if (type > 32) {
printf("%s", (char*)type);
type = va_arg(ap, uint64_t);
continue;
}
if (type == 1) {
printf("%lld", va_arg(ap, uint64_t));
} else if (type == 2) {
printf("%llx", va_arg(ap, uint64_t));
} else if (type == 3) {
printf("%f", va_arg(ap, double));
} else if (type == 4) {
printf("%p", (void*)va_arg(ap, uint64_t));
}
type = va_arg(ap, uint64_t);
}
printf("\n");
va_end(ap);
}

#define shit(...) \
do { \
uint64_t S=1, X=2, F=3, P=4; \
hidden_shit((uint64_t)0,__VA_ARGS__,(uint64_t)0);\
} while(0)


int main() {
int a = 123, b = 456, c = 666;
shit("hello world!");
shit("c=",S,c);
shit(S,a,",",F,456.0,",",X,b,",done");
char *verb = "go fuck", *object = "yourself", *adjective = "dumbfuck";
shit(verb," ",object,", ",adjective);
return 0;
}

Name: Anonymous 2021-03-10 19:30

Using NashC(tm)
#include <nsh.h>
#include <nsh/pp.h>

char *int.cstr {
int n = *this;
int l = snprintf(NULL, 0, "%d", n);
char *s = (char*)mAlloc(l+1);
sprintf(s, "%d", n);
return s;
}

char *float.cstr {
float n = *this;
int l = snprintf(NULL, 0, "%f", n);
char *s = (char*)mAlloc(l+1);
sprintf(s, "%f", n);
return s;
}

char *double.cstr {
float n = *this;
int l = snprintf(NULL, 0, "%f", n);
char *s = (char*)mAlloc(l+1);
sprintf(s, "%f", n);
return s;
}


char *char.cstr {
return this;
}

void say_impl_(int count, ...);

#if 0
#define say(...) \
do { \
say_impl_(PP_SIZE(__VA_ARGS__),__VA_ARGS__); \
} while(0)
#else
#define nsh_cstr(x) ((x).cstr)
#define say(...) \
do { \
printf("%s\n", catd(" ",PP_SIZE(__VA_ARGS__),PP_MAP(nsh_cstr,__VA_ARGS__)); \
} while(0)
#endif

int main() {
say("x =",123.456);
return 0;
}



Suddenly C becomes a bearable programming language. Just don't ask me how I do the GC.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List