- 1
https://github.com/JustKappaMan/SteamKeyGen
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
https://github.com/JustKappaMan/SteamKeyGen
0
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void *govno[300] = {NULL};
size_t govnopoindex = 0;
void chisti_govno(void)
{
do
{
free(govno[--govnopoindex]);
} while (govnopoindex != 0);
}
char *concat(char *a, char *b)
{
char *ptr = malloc(strlen(a)+strlen(b)+4);
if (ptr == NULL)
{
fprintf(stderr, "Huli ty obosralsya, mudak blyad? Ves' heap zasral\n");
chisti_govno(); // иди под струю мойся
exit(-1);
}
sprintf(ptr, "(%s*%s)", a, b);
govno[govnopoindex++] = ptr;
return ptr;
}
char *pow_gen(size_t n, char *a, char *p)
{
if (n == 0)
{
return a;
}
if (n & 1)
{
return pow_gen(n >> 1, concat(a, p), concat(p, p));
}
else
{
return pow_gen(n >> 1, a, concat(p, p));
}
}
char* pow_b2(size_t n) {
return pow_gen(n, "1", "a");
}
void printfshit(const size_t pow)
{
printf("double pow_%zu(double a) {return %s;}\n\n", pow, pow_b2(pow));
}
int main(void)
{
printfshit(255);
chisti_govno();
return 0;
}
http://govnokod.ru/23246#comment388959 - считаю что это заслуживает отдельного говнокода
+2
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *concat(char *a, char *b)
{
char *ptr = malloc(strlen(a)+strlen(b)+6);
if (ptr == NULL)
{
fprintf(stderr, "da ty ohuel!\n");
exit(-1);
}
sprintf(ptr, "(%s)*(%s)", a, b);
return ptr;
}
char *govno[255] = {"a"};
void printfshit(const size_t pow, const char *mul_stuff)
{
printf("double pow_%zu(double a) {return %s;}\n\n", pow, mul_stuff);
}
void genshit(void)
{
//printfshit(0,"1");
size_t end_ind = 1;
size_t prev_stop = 0;
size_t end_ind_tmp = 1;
while (end_ind < 255)
{
for (size_t ind1 = 0; ind1 < end_ind_tmp; ind1++)
{
for (size_t ind2 = prev_stop; ind2 < end_ind_tmp; ind2++)
{
if (
((ind1+1) + (ind2+1) < 256) &&
(govno[(ind1+1) + (ind2+1)-1] == NULL)
)
{
govno[(ind1+1) + (ind2+1)-1] = concat(govno[ind1], govno[ind2]);
end_ind++;
}
}
}
prev_stop = end_ind_tmp;
end_ind_tmp = end_ind;
}
printfshit(1,govno[0]);
for (size_t i = 1; i < 255; i++ )
{
printfshit(i+1,govno[i]);
free(govno[i]);
}
}
int main(void)
{
genshit();
return 0;
}
Кодогенератор, написаный специально для Antervis
http://govnokod.ru/23227#comment388895
0
#include <stdio.h>
#include <string.h>
#include <http_fetcher.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(argc != 2) { printf("Using: %s [url]\n", argv[0]); return 1; }
http_setTimeout(15);
if( http_setUserAgent("Mozilla/5.0 (Linux; Android 7.0; Pixel C Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36") == -1)
http_perror("setUserAgent");
http_setRedirects(15);
http_setReferer("http://no-site.ru/");
char *file_name = "";
if( http_parseFilename(argv[1], &file_name) == -1)
{ http_perror("parseFilename"); return 1; }
printf("Download file: %s\n", file_name);
char *buff = malloc(5000);
if( http_fetch(argv[1], &buff) == -1)
{ http_perror("fetch"); return 1; }
printf("Write on file..\n");
FILE *f = fopen(file_name, "a");
fprintf(f, "%s", buff);
fclose(f);
printf("Successfully written to file \"%s\"\n", file_name);
return 0;
}
Блять писал программу а она нихуя не контачит, ёбанная библиотека https не поддерживает!
Не используйте эту говно библиотеку
+2
#define UM8(CONST_FLOAT,CHISLO_INT) \
((CONST_FLOAT+1.0/16)<(1.0/8))?((CHISLO_INT*0)>>3):\
(((CONST_FLOAT+1.0/16)<(2.0/8))?((CHISLO_INT*1)>>3):\
(((CONST_FLOAT+1.0/16)<(3.0/8))?((CHISLO_INT*2)>>3):\
(((CONST_FLOAT+1.0/16)<(4.0/8))?((CHISLO_INT*3)>>3):\
(((CONST_FLOAT+1.0/16)<(5.0/8))?((CHISLO_INT*4)>>3):\
(((CONST_FLOAT+1.0/16)<(6.0/8))?((CHISLO_INT*5)>>3):\
(((CONST_FLOAT+1.0/16)<(7.0/8))?((CHISLO_INT*6)>>3):\
(((CONST_FLOAT+1.0/16)<(8.0/8))?((CHISLO_INT*7)>>3):\
(CHISLO_INT)\
)\
)\
)\
)\
)\
)\
)
https://habrahabr.ru/post/334758/
0
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int checkFile(char *s)
{
return ( open(s, O_RDONLY, 0) == -1) ? 0 : 1;
}
int main(int argc, char *argv[])
{
if(argc != 2) { printf("Тут один аргумент важен хуле\n"); return 1; }
if(checkFile(argv[1]))
{
int fd = open(argv[1], O_RDONLY, 0);
char buffer[1024];
read(fd, &buffer, sizeof(buffer));
printf("%s\n", buffer);
if( close(fd) == -1) perror("close");
}
else
printf("Файл не существует\n");
return 0;
}
Моя альтернатива программе cat, отсасывай cat ябучий!!
−1
BYTE1 *GetLanguageCodeString( BYTE1 upper, BYTE1 lower , BYTE1 *lang_idx )
{
int index = 0;
switch(upper){
case 'a' :
switch(lower){
case 'a' : index = 0; break;
case 'b' : index = 1; break;
case 'f' : index = 2; break;
case 'm': index = 3; break;
case 'r': index = 4; break;
case 's': index = 5; break;
case 'y': index = 6; break;
case 'z': index = 7; break;
default: break;
}
break;
case 'b' :
switch(lower){
case 'a' : index = 8; break;
case 'e' : index = 9; break;
case 'g' : index = 10; break;
case 'h': index = 11; break;
case 'i': index = 12; break;
case 'n': index = 13; break;
case 'o': index = 14; break;
case 's': index = 136; break; /* Added in SEIN 2004.04.01 KTJ */
default: break;
}
break;
case 'c' :
switch(lower){
case 'a' : index = 15; break;
case 'o' : index = 16; break;
case 's' : index = 17; break;
case 'y': index = 18; break;
default: break;
}
break;
case 'd' :
switch(lower){
case 'a' : index = 19; break;
case 'e' : index = 20; break;
case 'z' : index = 21; break;
default: break;
}
break;
case 'e' :
switch(lower){
case 'l' : index = 22; break;
case 'n' : index = 23; break;
case 'o' : index = 24; break;
case 's': index = 25; break;
case 't': index = 26; break;
case 'u': index = 27; break;
break;
}
break;
case 'f' :
switch(lower){
case 'a' : index = 28; break;
case 'i' : index = 29; break;
case 'j' : index = 30; break;
case 'o': index = 31; break;
case 'r': index = 32; break;
case 'y': index = 33; break;
default: break;
}
break;
case 'g' :
switch(lower){
case 'a' : index = 34; break;
case 'd' : index = 35; break;
case 'l' : index = 36; break;
case 'n': index = 37; break;
case 'u': index = 38; break;
default: break;
}
break;
case 'h' :
switch(lower){
case 'a' : index = 39; break;
case 'e' : index = 40; break;
case 'i' : index = 41; break;
case 'r': index = 42; break;
case 'u': index = 43; break;
case 'y': index = 44; break;
default: break;
}
break;
case 'i' :
switch(lower){
case 'a' : index = 45; break;
case 'd' : index = 46; break;
case 'k': index = 47; break;
case 'n': index = 48; break;
case 's': index = 49; break;
case 't': index = 50; break;
питушня на switch для распознавания какой-то фигни с буквами
+1
#define SPLICE(a,b) a##b
#define LL(a,b) SPLICE(a,b)
#define M(name) LL(NS,name)
#define NS ns1_
void M(somefunction)(){
}
#undef NS
#define NS ns2_
void M(somefunction)(){
}
#undef NS
#define NS ns3_
void M(somefunction)(){
}
#undef NS
неймспейсы в Си на препроцессоре
0
#include <stdio.h>
typedef int (*FUNC)();
FUNC test (int a, int b){
int ret(){
return a + b;
}
return ret;
}
int main(){
printf("%i\n", test(40, 2)());
return 0;
}
/* Тоже самое на JS */
function test(a, b){
function ret(){
return a + b;
}
return ret;
}
alert(test(40, 2)());
# Тоже самое на Python
def test(a, b):
def ret():
return a + b
return ret
print test(40, 2)()
Странно работает компилятор, версия: gcc version 4.7.2
$ gcc 1.c && ./a.out
42
$ gcc -O3 1.c && ./a.out
Segmentation fault
+1
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <stddef.h>
#define INITARR(arr,...) \
do \
{ \
typedef struct {typeof(*arr) __tmp_arr[sizeof( (typeof(*arr)[]){__VA_ARGS__} ) / sizeof(*arr)];} __tmp_str; \
*((__tmp_str *)arr) = (__tmp_str){{__VA_ARGS__}}; \
} while(0)
int main(void)
{
uint8_t *test;
test = malloc (sizeof (uint8_t[10]));
INITARR(test,1,2,3,4,5,6,7,8,9,10);
for (size_t i = 0; i < 10; i++)
{
printf("%" PRIu8 ", ", test[i]);
}
return 0;
}
Для удобной инициализации массивов в хипе