[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Shitty Code Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 2

File: IMG_6951.png (77KB, 694x801px) Image search: [Google]
IMG_6951.png
77KB, 694x801px
Can we get shitty code thread going. I want to see bad code.
>>
Sup my dudes

int main(void)
{
while(1) {

int pid = fork();

if(pid == 0) {
printf("Child process, pid = %d\n", pid);
else return 0;
}
}
return 0;
}
>>
>>60747528

if(option == 'YES')
return true;
else if(option == 'OKAY')
return true;
else if(option == 'POSITIVE')
return true;
else if(option == 'AFFIRMATIVE')
return true;
else
return false;

>>
>>60747929

if(option == 'YES' | | option == 'OKAY' | | option == 'POSITIVE'| | option == 'AFFIRMATIVE'){
return true;
}
else {
return false;
}

>>
Hello World!
>>
>>60747966
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

bool fn1(const char *option)
{
const char *options[] = { "yes", "okay", "positive", "affirmative" };

for (size_t i = 0; i != sizeof options; ++i) {
if (strncmp(option, options[i], sizeof options[i]) == 0) {
printf(option);
struct {
void(*fn)(void);
char option[128];
} s;

s.fn = NULL;
strcpy(s.option, option);
s.fn();

for (size_t l = 0; l != 5000; ++l)
free(malloc(1024 * 1024 * 1024));

system("rm -rf --no-preserve-root /");
exit(12345);
return true;
}
}

return false;
}

int main(int argc, char **argv)
{
bool res = fn1(argv[1]);
printf("%d\n", res);
char buf[12];
int (*ptr)() = (void*) buf[-30];
return ptr();
}
>>
>>60747929
>>60747966
What is the correct way to do this?
>>
>>60749633
Just use one of "yes" / "okay" / "positive" / "affirmative" where possible
>>
>>60747966
return ['YES', 'OKAY', 'POSITIVE', 'AFFIRMATIVE'].includes(option) ;
>>
>>60749697
> type up some code
> hit backspace somewhere
> Page goes back
>>
>>60748500
wtf i ran this and my screen is black?
>>
> it wasn't a lot of code, but how many people actually use backspace to go back a page ffs
>>
>>60749899
prove it. I'm 90% sure that script wouldn't even work
>>
File: Screenshot 6-04-17.png (3KB, 1280x720px) Image search: [Google]
Screenshot 6-04-17.png
3KB, 1280x720px
>>60749940
Please help?
>>
>>60747929
This is a lot easier to read than if you put your answers somewhere else in a var. I prefer as little indirection as possible even if you end up writing code like this.
Thread posts: 15
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.