Let's get 1000 by stupid C code (10)

1 Name: Captain Obvious 1993-09-4559 05:21 [no]

#include <stdio.h>
int main() {
char *s = "some words";
while (putchar(*(s = ++s))) ;
}

2 Name: Captain Obvious 1993-09-4559 05:21 [no]

#include <stdio.h>
char *fn(int i, char *s) {
while (i) {
s++;
i--;
}
return s;
}
int main(int argc, char **argv) {
int a = 2;
static char c[] = "test";
printf("%s\n", fn(a,c));
return 0;
}

3 Name: Captain Obvious 1993-09-4559 05:22 [no]

void
lolcpy(char *dest, const char *src) {
while ((*dest++ = *src++) != 0)
;
}

char *
lolchr(const char *s, int ch) {
do {
if (*s == ch) {
return s;
}
} while (*s++);
#define NULL ((void *)0)
return NULL;
}

typedef unsigned long size_t;

size_t
lollen(const char *s) {
const char *iter = s;

while (*iter) ++iter;
return iter - s;
}

int
main(void) {
int i;
char buf[123];
struct {
char *str;
size_t len;
} strings[] = {
{ "hello", 0 },
{ "blalalalallalaallalaalalla", 0 },
{ "", 0 },
{ " hmm hmmmm hmmmm", 0 },
{ NULL, 0 }
};

for (i = 0; strings[i].str != NULL; ++i) {
lolcpy(buf, strings[i].str);
strings[i].len = lollen(buf);
printf("`%s'=%lu(%lu)\n",
buf, strings[i].len, lolchr(buf, 0) - buf);
}
return 0;
}

4 Name: Captain Obvious 1993-09-4559 05:24 [no]

#include <stdio.h>
int main(void) {
int c, i;
while ((c = getchar()) != EOF) {
for (i = 7; i >= 0; i--) {
if (c & (1<<i))
putchar('1');
else
putchar('0');
}
putchar('\n');
}
return 0;
}

5 Name: Captain Obvious 1993-09-4559 05:37 [no]

int x=1, y=5;
x^=y^=x^=y; // what's the content of x and y now?

6 Name: Captain Obvious 1993-09-4559 05:41 [no]

i don't know how this thread works

7 Name: Captain Obvious 1993-09-4559 06:17 [no]

>>6

It doesn't.

8 Name: Captain Obvious 1993-09-4559 07:00 [no]

>>5
x holds a little badge given to you for proudly regurgitating this lame trick for the millionth time
y contains the :wtf: on your compiler's face as it won't optimize away a variable swap into a single instruction if possible, but will waste time doing 3 xors

oh wait this is /dqn/ not /code/, never mind

9 Name: Captain Obvious 1993-09-4559 12:12 [no]

i = (i&0x55555555) + (i>>1&0x55555555);
i = (i&0x33333333) + (i>>2&0x33333333);
i = (i&0x0f0f0f0f) + (i>>4&0x0f0f0f0f);
i = (i&0x00ff00ff) + (i>>8&0x00ff00ff);
i = (i&0x0000ffff) + (i>>16&0x0000ffff);

10 Name: Captain Obvious 1993-09-4559 13:29 [no]

       main(l
     ,a,n,d)char**a;{
  for(d=atoi(a[1])/10*80-
 atoi(a[2])/5-596;n="@NKA\
CLCCGZAAQBEAADAFaISADJABBA^\
SNLGAQABDAXIMBAACTBATAHDBAN\
ZcEMMCCCCAAhEIJFAEAAABAfHJE\
TBdFLDAANEfDNBPHdBcBBBEA_AL\
 H E L L O, W O R L D! "
   [l++-3];)for(;n-->64;)
    putchar(!d+++33^
        l&1);}

This thread has been closed. You cannot post in this thread any longer.