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

Pages: 1-4041-

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-02-23 0:09

bool Ruutu::onkoValmis()
{
if (lippu_ == true){
if (miina_ == true){
return true;
}else{
return false;
}
}
if (miina_ == true){
if (lippu_ == true){
return true;
}else{
return false;
}

}
if (onkoavattu_ == false){
if (miina_ == true){
return false;
}else{
return true;
}
}else{
return true;
}
}

Name: Mentifex 2018-02-23 2:55

Name: Anonymous 2018-02-23 3:58

*blocks your path*

remove_whitespace(non_null_terminated_string)

Name: Mentifex 2018-02-23 4:17

Name: Anonymous 2018-02-23 4:19

>>4
C functions don't validate input. strlen, strcat, and atoi will all usually segfault if you pass a bad string. The onus is on the caller to check inputs.

Name: Anonymous 2018-02-23 4:26

>>6
Its time to rewrite it in Rust then.

Name: Anonymous 2018-02-23 6:54

>>6
It's literally impossible to validate a C string without also passing an integer length (basically reinventing C++ std::string in a shittier more verbose way).

There is no guarantee that it's even possible for the calling code to validate it. E.g., argv[i] doesn't provide a length and many libraries follow that tradition.

Name: Anonymous 2018-02-23 9:28

loeb :: Functor f => f (f a -> a) -> f a
loeb x = go where go = fmap ($ go) x

Name: Anonymous 2018-02-23 10:14

#include "void.h" //gist.github.com/FrozenVoid/87e6ad6212ac9ce496e0#file-void-h"
STDSTART
/* advanced anaphoric macro stolen from LISP wizards
(defmacro aif (test-form then-form &optional else-form)
`(let ((it ,test-form))
(if it ,then-form ,else-form)))
(aif (+ 2 7)
(format nil "~A does not equal NIL." it)
(format nil "~A does equal NIL." it))
;; ? "9 does not equal NIL."
*/
#define aif(expr,action1,action2) ({auto master_programmer_secret_storage_device=expr;/*very advanced and known only to LISP wizards*/;\
if(0!=master_programmer_secret_storage_device/*powerful lambda-calculus mathemathics, you won't understand*/){action1;}else{/*extremely esoteric and arcane secondary path*/action2;};/*we don't return nothing, because the secret of master_programmer_secret_storage_device must be kept */;})
aif(2+7,p(master_programmer_secret_storage_device,"does not equal NULL."),p(master_programmer_secret_storage_device,"does equal NULL."));//p prints arguments to stdout or FILE* see textio.h https://gist.github.com/FrozenVoid/87e6ad6212ac9ce496e0
aif(0+0+1-2+1,p(master_programmer_secret_storage_device,"does not equal NULL."),p(master_programmer_secret_storage_device,"does equal NULL."));

STDEND

Name: Anonymous 2018-02-23 10:15

>>10
FrozenAnus is back? I hope he checks my repeating digits

Name: Anonymous 2018-02-23 15:22

>>11
No, this is him >>2

Name: Anonymous 2018-02-23 15:25

>>12
FrozenAnus is from Spurdoland? I though he's a bydlo. yeah, I know, it's about the lack of indents

Name: Anonymous 2018-02-23 16:25

pretty sure he's a bydlo whoring himself in spurdoland

Name: Anonymous 2018-02-24 4:28

>>13
I'm pretty sure FV is Russian.

Name: Anonymous 2018-02-25 21:21

>>>>12,13
FrozenAnus is RIP :-(.

Name: Anonymous 2018-02-26 2:23

Is removing white space the same as to make a safe space?

Name: Anonymous 2018-02-26 7:48

>>17
no

Name: Anonymous 2018-02-26 23:11

>>2
Error: Control reaches end of non void function.

Name: Mentifex 2018-02-27 5:30

Name: Anonymous 2018-02-27 8:10

>>20
cool!

Name: Anonymous 2018-02-27 8:11

>>21
nah

Name: Anonymous 2018-02-28 15:24

>>1

Mine is even better:

MOV r1, #0 ; j=0
LOOP CMP r1, #10 ; j<10?
BGE DONE ; if j >=10, finish

.
. ; instructions
.
ADD r1,r1, #1 ; j++
B LOOP
DONE ..

Name: Anonymous 2018-02-28 17:00

>>23
Put your tripcode back on Cudder.

Name: Anonymous 2018-03-03 20:37

die();

Name: Anonymous 2018-03-05 21:05

>>8
Well atof() could at least check for a NULL and set errno instead of segfaulting. I get that in C, you don't pay for what you don't need. Put adding a couple of instructions doesn't seem like a big deal for a function that already has a large number of instructions.

Name: Anonymous 2018-03-20 1:18

>>23
Prove that yours is better.

Name: Anonymous 2018-03-20 5:45

void fizzbuzz(int a, int b, int count){
int i;
for(i=0;i<=count;i++){
if( ! ((i%a==0?printf("fizz"):0)|(i%b==0?printf("buzz"):0)) ){
printf("%d",i);
}
printf("\n");
}
}

Name: Anonymous 2018-03-20 22:14

>>28
now do it with no conditionals like the guy from old /prog/

Name: Anonymous 2018-03-21 1:31

int main(int argc, char *argv[]);{
printf("fizzbuzz\n1\nfizz\n3\nfizz\nbuzz\nfizz\n7\nfizz\n9\nfizzbuzz\n11\nfizz\n13\nfizz\nbuzz\nfizz\n17\nfizz\n19\nfizzbuzz\n21\nfizz\n23\nfizz\nbuzz\nfizz\n27\nfizz\n29\nfizzbuzz\n31\nfizz\n33\nfizz\nbuzz\nfizz\n37\nfizz\n39\nfizzbuzz\n41\nfizz\n43\nfizz\nbuzz\nfizz\n47\nfizz\n49\nfizzbuzz\n51\nfizz\n53\nfizz\nbuzz\nfizz\n57\nfizz\n59\nfizzbuzz\n61\nfizz\n63\nfizz\nbuzz\nfizz\n67\nfizz\n69\nfizzbuzz\n71\nfizz\n73\nfizz\nbuzz\nfizz\n77\nfizz\n79\nfizzbuzz\n81\nfizz\n83\nfizz\nbuzz\nfizz\n87\nfizz\n89\nfizzbuzz\n91\nfizz\n93\nfizz\nbuzz\nfizz\n97\nfizz\n99\nfizzbuzz\n"
}

Name: Anonymous 2018-03-21 6:18

>>10
#include "void.h"//
gist.g ith ub.com
/Fro zenV
oid /87
e6 ad6
21 2a
c9 ce4
9 6e0
# fi l e-void
- h "S T DS T ART/*a
d v a n ced ana ph o ri cm acr
os to le n fr omL I SP wi za rd s
( d e fm a c r o aif (tes t- formt he n- fo
r m& opt ionale l se -fo rm)`( let ((it,t est-f or
m )) (if it,the n- for m,els e-form)))(aif (+27)(fo rm
at n il" ~Ad oes notequalNI L."it) (fo rmatnil" ~Adoeseq u
a l NIL ."it) );; ? "9do e snotequalN IL."*/#de fineaif(e xpr
, a cti o n1,acti o n2)({au t omaste r_prog r amm er_secret_s
t o rage_de vice= expr ;/*veryadva n
ce d a ndknownonly toLISPwiza rds*/;if(
0!= ma s t er _pr ogr amm er_sec
re t_ sto r a ge _d ev ice/*po
we r fulla m bd a- ca lculusma
th e mathi cs, you won 'tu nde r st
and * /){ action1;}e lse{/*ext re me ly
es o t er i ca nd
ar c a ne s ec on
da ry p a t h* /
ac ti o n 2; };/*wedon't r e t
ur n n ot h in g,b ec au s
e th ese c r et of m as t
e r_ pr og ra m mer _ se cr
e t_st o rage_dev ic em ustbek e pt * /
;} )aif (2 + 7,p(master_p rog ram mer_secret_s to rage_de
vi ce,"doe s notequalNULL."),p( master_programme r_ s
ec ret_ st orage_device,"doesequalNULL."));//pprintsargumentstostd ou torFI
L E* seet extio.hhttps://gist. github.com/FrozenVoid/ 8 7e6
ad 62 12 ac9ce496e0aif(0+0+1-2+1,p(ma ster_programmer_secr et_ st
or a ge _device,"doesno tequalNUL L."),p(master_progr amme r
_secret _s torage_device,"d oesequal NULL."));#inclu de" v oi
d.h"//gi st.github.com/Fro zenVoid /87e6ad6212ac9ce 496e0#f i le- v
oid-h"ST DSTART/*advanced anaphoric macrostolenfr omLISPwiza rds(def
ma croaif(test-f ormthen-f orm&optionalelse-fo rm)`(le t(( i
t,t est-form) )(ifit,then-form,else-f orm)))(aif(+27)(f orma tn il" ~A
doe sno tequalNIL."it)(formatnil"~Ad oesequalNIL."it));;?"9 doesn
ot equ alNIL."*/#defineaif(expr, a ction1,action2)({automaste
r _ prog rammer_secret_storage_ de vice=expr;/*verya d vanced
andkn ownon ly toLISPwizards*/;if (0!= ma ster_progra mm
er_sec ret _s torage_device/ *p owe rfulla m bd
a- ca l culusmathe ma thi cs,you wo

Name: not >>28 2018-03-21 8:22

>>29
look ma, no ifs!
#include <stdlib.h>
#include <stdio.h>

short anus_device;

void printnum(int c){
switch(anus_device){
case 0:
printf("%d",c);
case 1:
return;
}
}

void nop(int 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, printnum, printnum, printnum, printnum};

int main(int argc, char **argv){
int i, n;
switch(argc){
case 2:
if(argc < 2) return -1;
n = atoi(argv[1]);
for(i = 0; i < n; i++){
anus_device = 0;
(*fizz[i%3])(i);
(*buzz[i%5])(i);
puts("");
}
default:
return argc - 2;
}
}

Name: Anonymous 2018-03-21 8:24

look ma, dubs!

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);
}

Name: Anonymous 2018-03-21 9:48

>>34
doesn't work

Name: Anonymous 2018-03-21 9:51

>>35
plz elaborate. I do
gcc fizzbuzz_pointersonly.c
./a.out 100

and it works well enough:
FizzBuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz

Name: Negi Springfield !aeNZeP7XP2 2018-03-21 9:54

Name: Anonymous 2018-03-21 10:01

>>37
no u

Name: >>36, not >>38 2018-03-21 10:04

>>37
give me some time, gonna do it. doesn't seem that hard tbh

Name: Anonymous 2018-03-21 10:26

>>37
8 inch cock, you think you can handle that?

Name: Anonymous 2018-03-21 10:31

HANDLE MY ANUS

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;
}

Name: Anonymous 2018-03-21 14:39

>>42
Hope you didn't waste your precious work/neet time

Name: Anonymous 2018-03-21 14:43

I wasn't doing anything important anyway. also, check'em

Name: Anonymous 2018-03-21 16:37

There exist only 4 unary operations on binary input: invert (A->!A), maintain (A->A), nullify (A->0), validate (A->1).
Yet, nullify and validate can be thought of as nullary operations, merely inherited into unary space. Likewise, in binary operations, analogues to the (strictly) unaries exist, like maintain first (A,B->A), maintain second (A,B->B), invert first (A,B->!A) and invert second (A,B->!B).

Name: Anonymous 2018-03-21 18:07

>>32
Switch is a conditional idiot.

Name: Anonymous 2018-03-21 18:55

>>46
And you didn't see the if just after it? :/

Name: Anonymous 2018-03-22 7:50

>>46
ackchyually, switch is more like a computed goto (unfortunately, C lacks true computed goto). but I knew that someone will complain about it, that's why I made >>34. it even validates command-line arguments without conditionals!

Name: Anonymous 2018-03-22 13:20

>>48
switch is more like a computed goto
it's still a conditional

Name: Anonymous 2018-03-22 13:36

>>49
your're are mom is unconditionally a whore

Name: Anonymous 2018-03-22 14:01

>>50
#include<stdio.h>#include<stdlib.h>charstr[5]={'a','a'
,'a','a','a'};intcurrchar=0,endchar=0,ignore=0;voida_to_y()
{str[4-currchar]++;currchar=0;}voidz_standard(){str[4-currchar
++]='a';ignore++;}voidz_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};voidz(){(*handle_z[endchar-cu
rrchar])();}void(*handle_char[2])()={a_to_y,z};shorthandle_char_internal[2
6]={0};voiddo_print(char*s){puts(s);}voiddo_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;voidset_printer(){printer=printers[igno
re];}voidnop(){}voidend(){exit(0);}void(*on_new_endchar[6]) ()={nop,nop,nop,nop,n
op,end};intmain(){handle_char_inter nal[25]=1;ass:set_print er();(*printer)(&str[
4-endchar]);(*on_new_endchar[ endch ar])();(*handle_char[ha ndle_char_internal[s
tr[4-currchar]-'a']])();goto ass;} #include<stdio.h># incl ude<stdlib.h>charstr
[5]={'a','a','a','a','a'};intcurrchar=0,endchar=0,ignore=0;voida_to_y(){str[4-currch
ar]++;currchar=0;}voidz_sta nda rd(){str[4-currc har ++]='a';ignore++;}
voidz_end(){str[0]='a';st r[ 1]='a';str[2]=' a' ;str[3]='a';str [
4]='a';endchar++;currchar =0 ;}void(*handl e_ z[5])()={z_end ,
z_standard,z_standard,z_s tanda rd, z_standard} ; voidz(){(*han
dle_z[endchar-currchar])();}void(*handle _c har[2] )()={a_to_y ,z};shorthand
le_char_internal[26]={0} ;voiddo_print( ch ar*s ){puts(s);} voiddo_not_p
rint(char*s){ignore--; } void(*print er s[5])(ch ar*s)={do_pr
i nt,do_not_print,do_n o t_print,do_ n ot_print , do_not_prin
t };void(*printer)(char *s)=do_pri nt;voids et_printer(
) {printer=printers[ig nore];}vo idnop() {}voidend()
{ exit(0);}void(*on _n ew_endc har[6] )()={nop,nop
,nop,nop,nop,end} ;intmain(){h
andle_char_inter nal[25]=1
;ass:set_printer ();(*prin
ter)(&str[4-end char]);(*o
n_new_endchar[ endchar])
();(*handle_c har[handle
_char_internal [str[4-cu
rrchar]-'a']])( );goto ass;}#incl
u de<stdio.h>#incl ude<stdl ib.h>charst
r[5]={'a','a','a', 'a' ,'a'}; in
tcurrchar=0,endchar=0 ,ign ore= 0;
voida_to_y(){str[4-currch ar]++;c urrc h
ar=0;}voidz_standard(){str[4-currchar++]= 'a'
;ignore++;}voidz_end(){str[0]='a';str[1]= 'a
';str[2]='a';str[3]='a';str[4]='a';endcha
r++ ;currchar=0;}void(*handle_z[5])()={z_e
n d,z_standard,z_standard,z_standard,z_s
tandard};vo idz(){(*handle_ z[endchar
-currchar])();} void(*han d le_char[2]
)()={a_to_y,z};short handle_char_in
ternal[26]={0};voiddo_prin t(char*s){puts(s);}
voiddo_not_print(char*s){ignore--; }void(*printers[5])(char*
s)={do_print,do_not_print,do_not_ p rint,do_ not_print,do_not_print}
;void(*printer)(char*s)=do_pr int;voidset_printer(){printer=printe
rs[i gnore];}voidnop(){}voidend(){ exit(0);}void(*on_n ew_

Name: Anonymous 2018-03-22 14:05

>>49
It's a computed goto based on a conditional you fucking chode just like every other control staIHSBT

Name: Anonymous 2018-03-22 14:05

>>51
I don't think this will compile

Name: Anonymous 2018-03-22 18:08

>>53
Then you're not trying hard enough.

Name: Anonymous 2018-03-22 20:47

>>51
I enjoyed reading this.

Name: Anonymous 2018-03-22 22:28

>>8
There's a definition for the max length of *argv though, so I'm not sure that's a good example.

Name: Anonymous 2018-04-02 11:14

A script for copying favorited photos from your iOS device
#!/bin/sh
## https://brew.sh on macOS
# brew install libimobiledevice
# brew cask install osxfuse
# brew install ifuse
## or compile from http://www.libimobiledevice.org for Linux and Windows
## plug in your iOS device
## give your computer access
# idevicepair pair
## mount your iOS device's filesystem
# ifuse ~/iPhone

in=~/iPhone
out=~/Pictures/iPhone\ Favorites
mkdir -p "$out"

echo "SELECT ZDIRECTORY || '/' || ZFILENAME FROM ZGENERICASSET WHERE ZFAVORITE = 1;" \
| sqlite3 "$in/PhotoData/Photos.sqlite" \
| rsync -aP --files-from=- "$in" "$out"

Name: Anonymous 2018-04-03 11:04

#include <iostream>
using namespace std;

int main()
{
cout << "Hello, World!";
return 0;
}

Name: Anonymous 2018-04-03 16:36

echo 'hello world';

Name: Anonymous 2018-04-03 16:36

FUK this thred

Name: Anonymous 2018-04-03 17:59

>>60
HAX MY ANGUS

Name: Anonymous 2018-04-04 0:02

>>58
Why did you use an overloaded operator to print something to stdout?

Name: Anonymous 2018-04-04 6:22

>>62
OVERLOAD MY ANUS!!!!

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