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 12:39

>>37
it was trickier than I thought (with some annoying edge cases) but overall not too bad.
#include <stdio.h>
#include <stdlib.h>

char str[5] = {'a','a','a','a','a'};
int currchar=0, endchar=0, ignore=0;

void a_to_y(){
str[4-currchar]++;
currchar = 0;
}

void z_standard(){
str[4-currchar++]='a';
ignore++;
}

void z_end(){
str[0]='a';
str[1]='a';
str[2]='a';
str[3]='a';
str[4]='a';
endchar++;
currchar=0;
}

void (*handle_z[5])() = {z_end, z_standard, z_standard, z_standard, z_standard};

void z(){
(*handle_z[endchar-currchar])();
}

void (*handle_char[2])() = {a_to_y, z};
short handle_char_internal[26] = {0};

void do_print(char* s){
puts(s);
}

void do_not_print(char* s){
ignore--;
}

void (*printers[5])(char* s) = {do_print, do_not_print, do_not_print, do_not_print, do_not_print};

void (*printer)(char* s) = do_print;

void set_printer(){
printer = printers[ignore];
}

void nop(){}

void end(){
exit(0);
}

void (*on_new_endchar[6])() = {nop, nop, nop, nop, nop, end};

int main(){
handle_char_internal[25] = 1;
ass:
set_printer();
(*printer)(&str[4-endchar]);
(*on_new_endchar[endchar])();
(*handle_char[handle_char_internal[str[4-currchar]-'a']])();
goto ass;
}

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