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

Code Thread

Name: Anonymous 2018-02-23 0:05

This place has gone from programming themed garbage to just garbage. Post code. Any clean code. Here's a C function to remove whitespace.

void remove_whitespace(char *s) {
char *i = s;
do
if(!isspace(*i = *s))
++i;
while(*s++);
}

Name: Anonymous 2018-03-21 9:43

>>32
here's a (quick and dirty, plz no bully c*dder) version without ifs, loops and switches, just arrays of pointers and unconditional goto - but it's not portable (linux only)
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

short anus_device;

void nop(int c){}

void printnum(int c){
printf("%d",c);
}

void (*nobuzz[2])(int c) = {printnum, nop};

void afterfizz(int c){
(*nobuzz[anus_device])(c);
}

void fizz_f(int c){
printf("Fizz");
anus_device = 1;
}

void buzz_f(int c){
printf("Buzz");
}

void (*fizz[3])(int c) = {fizz_f, nop, nop};
void (*buzz[5])(int c) = {buzz_f, afterfizz, afterfizz, afterfizz, afterfizz};

void err(int argc, char **argv){
exit(argc-2);
}

void fizzbuzz(int c){
anus_device = 0;
(*fizz[c%3])(c);
(*buzz[c%5])(c);
puts("");
}

void exit_noerr(int c){
exit(0);
}

void (*fizzbuzz_or_exit[2])(int i) = {fizzbuzz, exit_noerr};

void actual_main(int argc, char **argv){
int i = 0, n = atoi(argv[1]);
short *should_exit = calloc(n+1, sizeof(short*));
should_exit[n] = 1;
ass:
(*fizzbuzz_or_exit[should_exit[i]])(i++);
goto ass;
}

short *argc_handling_internal;
void (*argc_handling[2])() = {err, actual_main};


int main(int argc, char **argv){
argc_handling_internal = calloc(sysconf(_SC_ARG_MAX), sizeof(short));
argc_handling_internal[2] = 1;
(*argc_handling[argc_handling_internal[argc]])(argc, argv);
}

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