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

Pages: 1-4041-8081-120121-

Most C programmers are faggots

Name: Anonymous 2012-01-29 19:36

I'm getting really irritated at a lot of self proclaimed C programmers for abusing the fuck out structures and pointers. It's easy to get out of hand and make your code look like shit and it seems people want to do it even when it's not necessary. The problem is even a lot of legitimately experienced C programmers do the same shit. Go look at the source to your favorite software written in C.

A good example is that stupid dubs checker thread that faggot just made. It should be written like this


#include <stdio.h>

#define base 10

int check(int i, int b) {
  return(i%b == (i/b)%b);
}

int main(void) {
  int i = 1;
 
  while(i++ < 100)
    if(check(i, base))
      puts("nice dubs bro");
     
  return(0);
}

Name: Anonymous 2012-01-29 19:44

Haskell programmer detected

Name: Anonymous 2012-01-29 19:48

return isn't a function
while isn't a function
if isn't a function.

Name: Anonymous 2012-01-29 19:49

>>3
No one implied it is. Go back to your toy languages.

Name: Anonymous 2012-01-29 19:51

Name: Anonymous 2012-01-29 19:52

>>4
The code implies that it is, read K&R you stupid piece of shit.

Name: Anonymous 2012-01-29 19:53

>>5
The Plan9 one is shit and the GNU one is good, tell me something that I don't know.

Name: Anonymous 2012-01-29 19:54

>>6
I've read my K&R you worthless piece of shit. Please post the passages from K&R that say the lack of a space between return, if, and while with its' parenthesis make it a function call.

Name: Anonymous 2012-01-29 20:01

>>8
Listen you dumb piece of crap, do I have to tell you what you have read? Are you seriously too fucking dumb to understand basic English? Do you even know what "imply" means? Go review basic education you fucking moron, your code sucks by the way, so you better rethink your life choices because you're never going to be a successful programmer. Now fuck off you fucking retard, your posts are worthless.

Name: Anonymous 2012-01-29 20:03

>>1-9
go scrub a toilet

Name: Anonymous 2012-01-29 20:07

>>9
Yeah you haven't actually read K&R. Fucking dumb shit. I can't believe you're dumb enough to think dmr's coding style is the only valid one.

Not only that, nowhere in K&R is it even said that spaces should be added in the first place.

Name: Anonymous 2012-01-29 20:27

>>11
It does in one of the exercises.

Name: HugePenis 2012-01-29 20:58

>>1
That code is buggy at best.

Name: Anonymous 2012-01-29 21:00

>>13
He is too unintelligent to even properly format his code, what do you expect?

Name: Anonymous 2012-01-29 21:03

>>9
Oh shit, do I know you? Did you do 30 days for bypassing a firewall?

Name: Anonymous 2012-01-29 21:17

>>14
Go scrub a toilet you mental midget.

Name: Anonymous 2012-01-29 21:20

>>13
Buggy doesn't mean that it won't work with faulty inputs.

Holy fuck you guys are terrible programmers.

Name: Anonymous 2012-01-29 21:23

>>16
Invent your own insults.

Name: Anonymous 2012-01-29 21:37

hacking around with structs and pointers is basically the whole point of C

Name: Anonymous 2012-01-29 21:46

>>18
Go scrub your own toilet you mental midget.

Name: Anonymous 2012-01-29 22:37

>>22
nice dubs bro

Name: Anonymous 2012-01-29 22:43

>>11
thanks, bro

Name: Anonymous 2012-01-29 22:53

>>6
The code implies that it is, read K&R you stupid piece of shit.
Read the UNIX source code you stupid piece of shit.

http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/cc.c

ctrl+f "return" faggot I dare you.

Keep browsing: http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd

Are you mad autist? Are you gonna go yell at dmr and ken now?

Name: Anonymous 2012-01-29 23:06

>>23
From the UNIX v7 source:

$ grep -r return\( usr/src/
usr/src/libdbm/dbm.c:        return(-1);
usr/src/libdbm/dbm.c:    return(0);
usr/src/libdbm/dbm.c:    return(blkno);
usr/src/libdbm/dbm.c:            return(item);
usr/src/libdbm/dbm.c:            return(item);
usr/src/libdbm/dbm.c:            return(-1);
usr/src/libdbm/dbm.c:    return(0);
usr/src/libdbm/dbm.c:    return(firsthash(0L));
usr/src/libdbm/dbm.c:        return(bitem);
usr/src/libdbm/dbm.c:        return(item);
usr/src/libdbm/dbm.c:    return(firsthash(hash));
usr/src/libdbm/dbm.c:        return(bitem);
usr/src/libdbm/dbm.c:        return(item);
usr/src/libdbm/dbm.c:        return(0);
usr/src/libdbm/dbm.c:        return(1);
usr/src/libdbm/dbm.c:    return(0);
usr/src/libdbm/dbm.c:    return(item);
usr/src/libdbm/dbm.c:    return(item);
usr/src/libdbm/dbm.c:        return(n - d2.dsize);
usr/src/libdbm/dbm.c:        return(0);
usr/src/libdbm/dbm.c:            return(*--p1 - *--p2);
usr/src/libdbm/dbm.c:    return(0);
usr/src/libdbm/dbm.c:            return(0L);
usr/src/libdbm/dbm.c:            return(hash|bit);
usr/src/libdbm/dbm.c:    return(hashl);
usr/src/libdbm/dbm.c:        return(-1);
usr/src/libdbm/dbm.c:    return(sp[0]-1);
usr/src/libmp/mdiv.c:    if(x>>15 ==0) { return(0);}
usr/src/libmp/mdiv.c:    { return(1);}
usr/src/libmp/mdiv.c:        else {return(d);}
usr/src/libmp/util.c:    if(i!=NULL) return(i);
usr/src/libmp/util.c:    return(0);
usr/src/libmp/util.c:        return(a);
usr/src/libmp/util.c:        return(a);
usr/src/libmp/util.c:        return(a);
usr/src/libmp/util.c:    if(a->len!=b->len) return(a->len-b->len);
usr/src/libmp/util.c:    return(res);
usr/src/libmp/msqrt.c:        return(0);
usr/src/libmp/msqrt.c:    return(r->len);
usr/src/libmp/mout.c:        return(0);
usr/src/libmp/mout.c:            return(0);
usr/src/libmp/mout.c:    return(EOF);
usr/src/libmp/mout.c:    return(m_in(a,10,stdin));
usr/src/libmp/mout.c:    return(m_in(a,8,stdin));
usr/src/libmp/mout.c:    return(m_in(a,10,f));
usr/src/libm/sinh.c:            return(temp);
usr/src/libm/sinh.c:            return(-temp);
usr/src/libm/sinh.c:        return(sign*(exp(arg) - exp(-arg))/2);
usr/src/libm/sinh.c:    return(sign*temp);
usr/src/libm/sinh.c:        return(exp(arg)/2);
usr/src/libm/sinh.c:    return((exp(arg) + exp(-arg))/2);
usr/src/libm/tan.c:                return(HUGE);
usr/src/libm/tan.c:            return(-HUGE);
usr/src/libm/tan.c:    return(sign*temp);
usr/src/libm/sqrt.c:        return(0.);
usr/src/libm/sqrt.c:    return(temp);
usr/src/libm/jn.c:    if(n==0) return(j0(x));
usr/src/libm/jn.c:    if(n==1) return(j1(x));
usr/src/libm/jn.c:    if(x == 0.) return(0.);
usr/src/libm/jn.c:    return(b);
usr/src/libm/jn.c:    return(t*j0(x)/b);
usr/src/libm/jn.c:        return(-HUGE);
usr/src/libm/jn.c:    if(n==0) return(y0(x));
usr/src/libm/jn.c:    if(n==1) return(sign*y1(x));
usr/src/libm/jn.c:    return(sign*b);
usr/src/libm/atan.c:        return(satan(arg));
usr/src/libm/atan.c:        return(-satan(-arg));
usr/src/libm/atan.c:        if(arg1 >= 0.) return(pio2);
usr/src/libm/atan.c:        else return(-pio2);
usr/src/libm/atan.c:            return(pio2+pio2 - satan(-arg1/arg2));
usr/src/libm/atan.c:            return(-pio2-pio2 + satan(arg1/arg2));
usr/src/libm/atan.c:        return(satan(arg1/arg2));
usr/src/libm/atan.c:        return(-satan(-arg1/arg2));
usr/src/libm/atan.c:        return(xatan(arg));
usr/src/libm/atan.c:        return(pio2 - xatan(1.0/arg));
usr/src/libm/atan.c:        return(pio4 + xatan((arg-1.0)/(arg+1.0)));
usr/src/libm/atan.c:    return(value*arg);
usr/src/libm/j1.c:        return(n);
usr/src/libm/j1.c:    return(arg*n/d);
usr/src/libm/j1.c:        return(-HUGE);
usr/src/libm/j1.c:        return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n)));
usr/src/libm/j1.c:    return(x*n/d + tpi*(j1(x)*log(x)-1./x));
usr/src/libm/asin.c:        return(0.);
usr/src/libm/asin.c:    return(sign*temp);
usr/src/libm/asin.c:        return(0.);
usr/src/libm/asin.c:    return(pio2 - asin(arg));
usr/src/libm/pow.c:            return(0.);
usr/src/libm/pow.c:        return(temp);
usr/src/libm/pow.c:    return(exp(arg2 * log(arg1)));
usr/src/libm/pow.c:    return(0.);
usr/src/libm/tanh.c:        return(sign);
usr/src/libm/tanh.c:    return(sign*sinh(arg)/cosh(arg));
usr/src/libm/floor.c:    return(d);
usr/src/libm/floor.c:    return(-floor(-d));
usr/src/libm/exp.c:        return(1.);
usr/src/libm/exp.c:        return(0.);
usr/src/libm/exp.c:        return(HUGE);
usr/src/libm/exp.c:    return(ldexp(sqrt2*(temp2+temp1)/(temp2-temp1), ent));
usr/src/libm/hypot.c:    if(b==0) return(0.);
usr/src/libm/hypot.c:    return(b*sqrt(1. + a*a));
usr/src/libm/hypot.c:    return(hypot(arg.r, arg.i));
usr/src/libm/sin.c:    return(sinus(arg, 1));
usr/src/libm/sin.c:    return(sinus(arg, 0));
usr/src/libm/sin.c:    return(temp1/temp2);
usr/src/libm/j0.c:        return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n)));
usr/src/libm/j0.c:    return(n/d);
usr/src/libm/j0.c:        return(-HUGE);
usr/src/libm/j0.c:        return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n)));
usr/src/libm/j0.c:    return(n/d + tpi*j0(arg)*log(arg));
usr/src/libm/fabs.c:    return(arg);
usr/src/libm/log.c:        return(-HUGE);
usr/src/libm/log.c:    return(temp);
usr/src/libm/log.c:    return(log(arg)/ln10);
usr/src/libc/gen/strcmp.c:            return(0);
usr/src/libc/gen/strcmp.c:    return(*s1 - *--s2);
usr/src/libc/gen/strncpy.c:            return(os1);
usr/src/libc/gen/strncpy.c:    return(os1);
usr/src/libc/gen/rand.c:    return(((randx = randx*1103515245 + 12345)>>16) & 077777);
usr/src/libc/gen/pkon.c:        return(-1);
usr/src/libc/gen/pkon.c:    return(turnon(fd, size, 2, 0));
usr/src/libc/gen/pkon.c:        return(-1);
usr/src/libc/gen/pkon.c:    return(p.psize);
usr/src/libc/gen/pkon.c:    return(ioctl(fd,TIOCSETD,&p));
usr/src/libc/gen/execvp.c:    return(execvp(name, &argv));
usr/src/libc/gen/execvp.c:                    return(-1);
usr/src/libc/gen/execvp.c:            return(-1);
usr/src/libc/gen/execvp.c:                return(-1);
usr/src/libc/gen/execvp.c:            return(-1);
usr/src/libc/gen/execvp.c:    return(-1);
usr/src/libc/gen/execvp.c:    return(*s1? ++s1: 0);
usr/src/libc/gen/setjmp.s:// will generate a "return(v)" from
usr/src/libc/gen/ttyname.c:        return(NULL);
usr/src/libc/gen/ttyname.c:        return(NULL);
usr/src/libc/gen/ttyname.c:        return(NULL);
usr/src/libc/gen/ttyname.c:        return(NULL);
usr/src/libc/gen/ttyname.c:            return(rbuf);
usr/src/libc/gen/ttyname.c:    return(NULL);
usr/src/libc/gen/atof.c:    return(fl);
usr/src/libc/gen/malloc.c:                    return(NULL);
usr/src/libc/gen/malloc.c:            return(NULL);
usr/src/libc/gen/malloc.c:                return(NULL);
usr/src/libc/gen/malloc.c:    return((char *)(p+1));
usr/src/libc/gen/malloc.c:        return((char *)q);
usr/src/libc/gen/malloc.c:    return((char *)q);
usr/src/libc/gen/malloc.c:        return(1);
usr/src/libc/gen/malloc.c:    return(r==allocb&(x==1|p==q));
usr/src/libc/gen/malloc.c:    return(q>=allocb);
usr/src/libc/gen/strcat.c:    return(os1);
usr/src/libc/gen/strcpy.c:    return(os1);
usr/src/libc/gen/abs.c:    return(arg);
usr/src/libc/gen/getlogin.c:        return(0);
usr/src/libc/gen/getlogin.c:        return(0);
usr/src/libc/gen/getlogin.c:        return(0);
usr/src/libc/gen/getlogin.c:    return( ubuf.ut_name );
usr/src/libc/gen/nlist.c:        return(-1);
usr/src/libc/gen/nlist.c:        return(-1);
usr/src/libc/gen/nlist.c:    return(0);
usr/src/libc/gen/isatty.c:        return(0);
usr/src/libc/gen/isatty.c:    return(1);
usr/src/libc/gen/atol.c:    return(f? -n: n);
usr/src/libc/gen/ttyslot.c:        return(0);
usr/src/libc/gen/ttyslot.c:        return(0);
usr/src/libc/gen/ttyslot.c:            return(s);
usr/src/libc/gen/ttyslot.c:    return(0);
usr/src/libc/gen/ttyslot.c:            return(NULL);
usr/src/libc/gen/ttyslot.c:            return(line+2);
usr/src/libc/gen/ttyslot.c:            return(line+2);
usr/src/libc/gen/strncat.c:    return(os1);
usr/src/libc/gen/mpx.c:        return(mpxcall(MPX, &vec));
usr/src/libc/gen/mpx.c:        return(mpxcall(MPXN, 0));
usr/src/libc/gen/mpx.c:    return(mpxcall(CHAN, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(JOIN, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(CONNECT, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(ATTACH, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(DETACH, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(EXTR, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(DEBUG, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(NPGRP, &vec));
usr/src/libc/gen/mpx.c:    return(mpxcall(CSIG, &vec));
usr/src/libc/gen/calloc.c:        return(NULL);
usr/src/libc/gen/calloc.c:    return(mp);
usr/src/libc/gen/ecvt.c:    return(cvt(arg, ndigits, decpt, sign, 1));
usr/src/libc/gen/ecvt.c:    return(cvt(arg, ndigits, decpt, sign, 0));
usr/src/libc/gen/ecvt.c:        return(buf);
usr/src/libc/gen/ecvt.c:        return(buf);
usr/src/libc/gen/ecvt.c:    return(buf);
usr/src/libc/gen/crypt.c:    return(iobuf);
usr/src/libc/gen/timezone.c:                return(zp->dlzone);
usr/src/libc/gen/timezone.c:                return(zp->stdzone);
usr/src/libc/gen/timezone.c:    return(czone);
usr/src/libc/gen/index.c:            return(sp);
usr/src/libc/gen/index.c:    return(NULL);
usr/src/libc/gen/mktemp.c:            return("/");
usr/src/libc/gen/mktemp.c:    return(as);
usr/src/libc/gen/atoi.c:    return(f? -n: n);
usr/src/libc/gen/ctime.c:    return(asctime(localtime(t)));
usr/src/libc/gen/ctime.c:    return(ct);
usr/src/libc/gen/ctime.c:    return(d - (d - t->tm_yday + t->tm_wday + 700) % 7);
usr/src/libc/gen/ctime.c:    return(&xtime);
usr/src/libc/gen/ctime.c:    return(cbuf);
usr/src/libc/gen/ctime.c:        return(366);
usr/src/libc/gen/ctime.c:    return(365);
usr/src/libc/gen/ctime.c:    return(cp);
usr/src/libc/gen/strlen.c:    return(n);
usr/src/libc/gen/rindex.c:    return(r);
usr/src/libc/gen/getenv.c:            return(v);
usr/src/libc/gen/getenv.c:    return(NULL);
usr/src/libc/gen/getenv.c:            return(s2);
usr/src/libc/gen/getenv.c:        return(s2);
usr/src/libc/gen/getenv.c:    return(NULL);
usr/src/libc/gen/strncmp.c:            return(0);
usr/src/libc/gen/strncmp.c:    return(n<0 ? 0 : *s1 - *--s2);
usr/src/libc/gen/stty.c:    return(ioctl(fd, TIOCSETP, ap));
usr/src/libc/gen/stty.c:    return(ioctl(fd, TIOCGETP, ap));
usr/src/libc/gen/tell.c:    return(lseek(f, 0L, 1));
usr/src/libc/stdio/findiop.c:            return(NULL);
usr/src/libc/stdio/findiop.c:    return(iop);
usr/src/libc/stdio/ftell.c:        return(-1);
usr/src/libc/stdio/ftell.c:        return(tres);
...

Name: Anonymous 2012-01-29 23:10

>>24
You sure told that mental midget.

Name: Anonymous 2012-01-29 23:38

>>25
Sure is angry denialist

Name: Anonymous 2012-01-29 23:43

░░░░░░░░░░░░░░░▄░░░░░░░░░░░░░░░
░░░░░░░░░░░░░▄▀█░░░░░░░░░░░░░░░
░░░░░░░░░░░▄▀░░█░░░░░░░░░░░░░░░
░░░░░░░░░▄▀░░▄▀░░░░░░░░░░░░░░░░
░░░░░░░░█▄░▄▀░░░░░░░░▄█▄░░░░░░░
░░░░░░░░█░▀▄░░░░░░░▄▀░█░▀▄░░░░░
░░░░░░░░▀▄░░▀▄░░░▄▀░░▄▀▄░░▀▄░░░
░▄░░░░░░░░▀▄░░▀▄▀░░▄▀░░░▀▄░░▀▄░
░█▀▄░░░░░░░░▀▄▀█▀▄▀░░░░░░░▀▄░█░
░█░░▀▄░░░░░▄▀░░█░░▀▄░░░░░░░░▀█░
░░▀▄░░▀▄░▄▀░░▄▀░▀▄░░▀▄░░░░░░░░░
░░░░▀▄░░█░░▄▀░░░░░▀▄░▄█░░░░░░░░
░░░░░░▀▄█▄▀░░░░░░░░▄▀░█░░░░░░░░
░░░░░░░░▀░░░░░░░░▄▀░░▄▀░░░░░░░░
░░░░░░░░░░░░░░░▄▀░░▄▀░░░░░░░░░░
░░░░░░░░░░░░░░░█░▄▀░░░░░░░░░░░░
░░░░░░░░░░░░░░░█▀░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░█▄░█░█░▄▀▀▄░░█░░█░█▀▀░▀█▀░█░░░
░█░█▄░█░█░▄▄░░█▄▄█░█▄▄░░█░░█░░░
░█░░█░█░▀▄▄▀░░█░░█░█▄▄░▄█▄░█▄▄░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

Name: Anonymous 2012-01-30 0:15

I feel the love.

Name: Anonymous 2012-01-30 1:05

>>19
No it's not. People like you are the reason no one sees the beauty in C.

Name: Anonymous 2012-01-30 2:26

>>29
There's no beauty in C. That's what I like about it. It's awkward and close to the hardware and has no pretenses. It's a language for manipulating memory. That's it.

Name: Anonymous 2012-01-30 2:35

>>30
That's why you embed higher level languages into it. Perfect combination.

Name: Anonymous 2012-01-30 3:03

>>30
Its simplicity, orthogonality and extensibility make it beautiful. C is a very simple language and its power comes from combining simple parts to make a more powerful whole. All of the complex declarations and data types in C can be decomposed into simpler parts. In contrast to other languages where operations like I/O and memory allocation are accessed using a fixed set of statements or keywords, C uses standard library functions that appear exactly like any other functions.

Name: Anonymous 2012-01-30 4:08

Most dubs getters are faggots.



Not i

Name: Anonymous 2012-01-30 5:27

>>33
puts("nice dubs bro");

Name: Anonymous 2012-01-30 6:21

Who is Bonky the Koala?

Name: Anonymous 2012-01-30 6:41

I was just about to commend /prog/ about how its quality has improved over the last few days. Ah well.

>>1
While I get what you are saying, using pointers over array subscripts actually tends to give you a slight boost in performance.

There is definitely a tendency to get away from the UNIX philosophy of keeping everything as simple as it can be while achieving optimal results, where complex mechanisms are used for the simplest of tasks, but I think pointers are needlessly feared.

Likewise, prototypes are important for reusability. If anyone were to reuse your dub-checker the lack of prototypes would turn off all type-checking for external calls. This is bad.

>>3
They are key words, my dear troll. Go ahead and try to make a function named if.

Name: Anonymous 2012-01-30 7:06

I am the guy who did the checker yesterday.

While the formula i%b == (i/b)%b is a *very* nice hack, what if I want to include trips and quads later? While it is flexible by accepting any given base, it's only a boolean for answer. NOT what I had in mind. I had in mind telling what the number might be too, not just saying "hey, there's dubs in base 13. to find it, go fuck yourself".

My solution unites the hackish of dealing with basic pointers and structures with ENTERPRISE level possibilities of expanding. With basically a little loop and a pointer change, the program is able to see dubs, trips, quads... The user name it.

All in my first program in pure C. Sorry if it isn't a compiler.

Name: Anonymous 2012-01-30 7:27

>>37
Fuck off with your gnu bloat faggot

Name: Anonymous 2012-01-30 7:28

>>38

Care to explain WHY it's a "GNU bloat"?

Name: Anonymous 2012-01-30 7:30

>>39
I doubt he can. Those who are lost to anger rarely recover. All they do is lash out and tear down what they cannot build.

Name: Anonymous 2012-01-30 7:44

>>36

I think quality has improved. Not all contributions needs to be from PHDs. Both implementations are a fun read, even if "wrong". There were a few really good questions and answers, and if there's a suitable trolling/discussing ratio, the community can only improve.

Compared to the wasteland of the last year, seems like a good start.

Name: Anonymous 2012-01-30 11:49

C is shit.
Use x86 asm.

Name: Anonymous 2012-01-30 11:50

>>42
x86 came from a Jew's distended anus

Name: Anonymous 2012-01-30 13:34

>>43
fuck off, faggot

Name: Anonymous 2012-01-30 15:05

>>36
Why are you upset at the thread? Is it >>1 or the replies?

Name: Anonymous 2012-01-30 15:20

>>37
I'm sorry bro, but I simply found a better way. Your method is too bloat.


#include <stdio.h>

int check(int num, int base, int k) { /*  for k 2 is dubs, 3 is trips, etc. */
  int i = 0, digit, last_digit;
 
  last_digit = num % base;
  while(++i < k) {
    digit = last_digit;
    if(digit == (num/=base)%base)
      last_digit = digit;
    else
      return(0);
  }
 
  return(1);
}

int main(void) {
  if(check(33, 10, 2)) puts("nice dubs");
  if(check(111, 10, 3)) puts("nice trips");
  if(check(15, 2, 4)) puts("nice quads");
  if(check(16, 2, 4)) puts("nice quads again");
  if(check(17, 2, 4)) puts("shouldn't print");
  if(check(12, 10, 2)) puts("shouldn't print");
 
  return(0);
}

Name: Anonymous 2012-01-30 15:27

>>46
while isn't a function
if isn't a function
return isn't a function.

Name: Anonymous 2012-01-30 15:29

>>47
see >>24

Name: Anonymous 2012-01-30 15:32

>>47
http://minnie.tuhs.org/cgi-bin/utree.pl?file=pdp11v/usr/src/cmd/ls.c
while((c=fgetc(type ? pwdfg : pwdfu)) != '\n')
if(p2->lmtime == p1->lmtime)
return(0);
U MAD?

Name: Anonymous 2012-01-30 15:53

>>37
$ cat dubs.c
#include <stdio.h>
#include <stdlib.h>
#define MAX_BASE 36

const char *alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWYZ";
const char *names[] = {
  NULL, NULL, "dubs", "trips",
  "quads", "quints", "sexts",
  "septs", "octs", "nons",
};

/* Actual dubs checking: four lines of code. */
int check(int num, int base) {
  int count = 0, digit = num % base;
  while (num % base == digit) {
    count++; num /= base;
  }
  return count;
}

int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <postnum>\n", argv[0]);
    return 1;
  }

  int postnum = atoi(argv[1]), base, result;

  if (postnum <= 0) {
    fprintf(stderr, "Invalid post number: %s\n", argv[1]);
    return 1;
  }

  for (base = 2; base < postnum && base < MAX_BASE; base++) {
    result = check(postnum, base);
    if (result < 2) continue;

    if (result >= 10) {
      printf("* %ds in base %d: ", result, base);
    } else {
      printf("* %s in base %d: ", names[result], base);
    }

    while (result--) {
      putchar(alphabet[postnum % base]);
    }
    putchar('\n');
  }

  return 0;
}

$ gcc -o dubs dubs.c && ./dubs 39
* trips in base 2: 111
* dubs in base 12: 33

Name: Anonymous 2012-01-30 16:21

>>50
nice code bro

Name: Anonymous 2012-01-30 16:21

>>36
| using pointers over array subscripts actually tends to give you a slight boost in performance
What makes you say that? Whether you dereference a pointer or use array subscript notation won't make a difference.

Name: Anonymous 2012-01-30 16:46

>>50

NOW that's some good teaching. I finally realized how the formula is working. Cool stuff, thanks.

I'm still happy that at least my bloated way works

Name: kodak_gallery_programmer !!qmiXqQhekkGXVVD 2012-01-30 16:58

>>39
>Care to explain WHY it's a "GNU bloat"?

Because when you compile a C program under the GNU C compiler, the compiler, by default, will leave on a bunch of GNU specific extensions.

Name: Anonymous 2012-01-30 16:59

>>52
Array[i] is instantly converted into *(address of the first element of the array+i) in C, behind the scenes. Dereferencing a pointer is just *(adress). If you are running along an array and increasing i each time, it is slightly more efficient to increase a pointer each time and dereference it rather than increase i each time and then add it to the pointer.

Furthermore, if you pass an array to a function what you are passing is an automatic pointer to its first element. Since you already have a pointer separate from from the one 'holding' the array, you can use it to run along the array as long as you do not need to do more than one pass over the array. Defining an additional variable to do what one you already have is capable of is wasteful in this situation.

Name: Anonymous 2012-01-30 17:06

>>55
Array[i] is instantly converted into *(address of the first element of the array+i) in C.

That only happens when you when an array is passed to a function. Otherwise no special conversion happens.

Dereferencing a pointer is just *(adress).

Again, that's incorrect.

Name: Anonymous 2012-01-30 17:06

>>54

But what if another compiler is used? The code has nothing to do with it, so it's not GNU bloat.

Name: Anonymous 2012-01-30 17:08

>>55
Also..

you already have a pointer separate from from the one 'holding' the array

I think you just need to shut your mouth on something you clearly don't understand, and like, maybe write some C code.

Name: Anonymous 2012-01-30 17:11

>>57
Try this you moron. Write a program that uses popen(). By default, when you compile it using the GNU C compiler, there will be no warnings. Now take this same piece of code and try to compile it on a Windows box.

So why would it compile do a clean build on one box and not another? It's because of the bloat GNU extensions.

Name: Anonymous 2012-01-30 17:19

>>56
>That only happens when you when an array is passed to a function. Otherwise no special conversion happens.

'In evaluating a[i], C converts it to *(a+i) immediately; the two forms are equivalent.' - K&R page 99

>Again, that's incorrect.
How so?

>>58
An array name is essentially a pointer constant.

Name: Anonymous 2012-01-30 17:23

>>60
No. An array name is the "name of an array". In C, an array and an array element are two different things.

Name: Anonymous 2012-01-30 17:27

>>61
That is implied since the elements are not constants all pointing to the first element..

Name: Anonymous 2012-01-30 17:37

>>62
No it's not you dumbass. Again, I think you just need to shut the fuck up and write some actual C code instead of googling shit.

Name: Anonymous 2012-01-30 17:38

>>62
Pstt... one is modifiable, the other one isn't. Of course the only way your dumbass would know something like this is if you would have

a)Read one of the standards.
b)Written some C code.

Name: Anonymous 2012-01-30 17:39

>>63
Its cool that you apparently know the language better than the guy who invented it and wrote the manual. That is why you don't actually need to refute the quote from the book or back any of what you are saying, right?

Name: Anonymous 2012-01-30 17:42

>>65
You're not drawing a clear distinction between an array and an array element. Now shut up. You're not only fucking stupid, but you're also fucking annoying. Now scrub another toilet you fucking mental midget.

Name: Anonymous 2012-01-30 17:43

>>65
I'm not the one making retarded statements. In your case, since you are a total fucking dumbass, I would cite either the standard or K & R. This is because you don't have the mental capacity to put this shit into your own words.

Name: Anonymous 2012-01-30 17:47

>>66
Where did I mix up an array and its elements?

>>67
Yes, you are the one contradicting K&R.

Name: Anonymous 2012-01-30 17:50

>>68
When you said the following..

>An array name is essentially a pointer constant.

Name: Anonymous 2012-01-30 17:51

>>68
Again, you're stupid. And again, you have no possible future as a computer programmer.

Name: Anonymous 2012-01-30 17:53

>>69
An array's name is used to refer to the address of its first element. It is NOT the first element. The two are distinct.

Name: Anonymous 2012-01-30 17:55

>>24

Just because the syntax for return, if, and while is similar to the syntax for function calls does not mean that they are functions. They're statements. Technically not even functions in C are really functions, they're subroutines/procedures, but that's true of most languages.

Name: Anonymous 2012-01-30 17:55

>>71
No you stupid fucker. For the second time, an "array" and an "array element" are two different things.

Name: Anonymous 2012-01-30 17:56

>>70
Show, don't tell, my dear Kodak. I gave you a direct quote from the horse's mouth. For one who admires standards so much you have not, as of yet, shown me in an official document that I am wrong. Writing angry words in my general direction will not actually prove anything beyond the fact that you are vexed.

Name: Anonymous 2012-01-30 17:56

>>71
Again, reread the passage you stupid fucker.

Name: Anonymous 2012-01-30 17:57

>>74
Again, you're a total dumbass. Now reread the passage again you mental midget.

Name: Anonymous 2012-01-30 17:58

>>73
Mother of god. A variable holding an address is not whatever lies in the address it is holding.

Name: Anonymous 2012-01-30 17:58

Also, nowhere does K & R say the following..

>An array name is essentially a pointer constant.

Name: Anonymous 2012-01-30 17:59

>>78
So, you accept you were wrong on the two other points?

Name: Anonymous 2012-01-30 18:00

>>77
>A variable holding an address is not whatever lies in the address it is holding.

Stop making up your own fucking interpretation of the language you moron.

Name: Anonymous 2012-01-30 18:01

>>80
So, according to you, a pointer is whatever it is pointing to?

Name: Anonymous 2012-01-30 18:01

>>79
This

An array name is essentially a pointer constant.

Is not correct. Look up the phrase "pointer constant" in one of tne standards you fucking moron.

Name: Anonymous 2012-01-30 18:02

>>81
I never said nor implied that. Again, I think you need to cite citing the standard since you don't have the mental capacity to put anything you've read into your own words.

Name: Anonymous 2012-01-30 18:06

Hint: if you use the word "moron" during a discussion to fortify your arguments, that's a sign you're pretty bad at discussing. If you're not using it to fortify your arguments, then don't type it out. I'm looking at you, >>83 and/or kodak.

Name: Anonymous 2012-01-30 18:13

>>82
An array's name is primarily used in the following contexts:
To pass it to a function - example: f(arr) - in which case what is passed is the address of the first element.
To access one of its members - example: arr[i] - in which case it is converted to the form *(arr+i), arr again replacing the address of the first element.
To assign the array's first member to a pointer without specifying which member in the previous form of arr[i] - example: int *ptr=arr - in which case the array's name is again synonymous for the address of the first element.

In every context in which an array's name is used, it is treated as the address of the first element. Thus one can think of an array's name as a pointer who's value cannot be changed.

Even in the internal representation, if you want to access anything, you need its address.

Name: Anonymous 2012-01-30 18:13

>>84
Again, for the third time, I'm not the dumbass that said...

>An array name is essentially a pointer constant.

This statement alone implies that you are totally clueless. Again, I think you just need to shut the fuck up and read the standard. Because again, you clearly don't have the mental capacity to put what you read into your own words.

Name: Anonymous 2012-01-30 18:15

>>85
Clicked reply too soon.

A name is just a reference.

Name: Anonymous 2012-01-30 18:17

I am infinitely amused you have locked on to the one thing I could not provide a concrete quote on and focused on that, refusing to admit you were wrong on what I did prove.

Name: Anonymous 2012-01-30 18:19

>>85
To access one of its members - example: arr[i] - in which case it is converted to the form *(arr+i), arr again replacing the address of the first element.

I can cite three cases where this isn't true.

Name: Anonymous 2012-01-30 18:20

>>87
>A name is just a reference.

No you stupid shit. A name is an *identifier*. Man, I swear, you are one stupid son of a bitch.

Name: Anonymous 2012-01-30 18:21

>>88
You are wrong on a few other things. However, you seem to have gotten your panties in a bundle when I called you out for the stupid shit that you are.

Name: Anonymous 2012-01-30 18:21

>>89
Cite away my friend. Keeping in mind

>>60

Name: Anonymous 2012-01-30 18:26

>>92
This..

>Array[i] is instantly converted into *(address of the first element of the array+i) in C,

Is also wrong.

Name: Anonymous 2012-01-30 18:28

>>93
Again, K&R disagrees. I even gave you the exact quote and the page number. How hard is this for you to check?

Name: Anonymous 2012-01-30 18:29

ITT C++ programmers.

Name: Anonymous 2012-01-30 18:36

>>94
I have the book. Nowhere does it say "It's not *(address of the first element of the array + i)". Again, this is because you are giving your own creative interpretation of the language.

Name: Anonymous 2012-01-30 18:38

>>94
Nowhere in the book does it say

>Array[i] is instantly converted into *(address of the first element of the array+i) in C,

Only you are saying this. Because again, you are giving your own creative interpretation of the language.

Name: Anonymous 2012-01-30 18:40

>>94
Should I continue on you mental midget? Again, you're fucking stupid. And again, you have no possible future as a computer programmer.

Name: Anonymous 2012-01-30 18:43

>>96
Cool. Then what does the quote 'In evaluating a[i], C converts it to *(a+i) immediately; the two forms are equivalent.' (p99 2e) means?

'Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster but, at least to the uninitiated, somewhat harder to understand.' (p97 2e) Why would the pointer version would be, generally, faster if the above is not true?

Name: Anonymous 2012-01-30 18:45

Check my dubs.

Name: Anonymous 2012-01-30 18:46

>>99
Exactly what it means. The fact that you insist it's an address just implies that you're a mental midget. The fact that you got your panties in a bundle about this means that not only are you a mental midget, but also, that you're a retard.

Nice job faggot. You're below average.

Name: Anonymous 2012-01-30 18:48

>>100
Nice dubs bro

>>101
>Exactly what it means.
Cool. Guess I'm right then.

Name: Anonymous 2012-01-30 18:53

>>102
Right about what? Nowhere does it say it's an address. A possible reason for this wording might be because on some computers, the offset in an array isn't an address. Now again, stop giving your own creative description of the langauge you fucking moron.

Name: Anonymous 2012-01-30 18:55

>>102
Here's a possible scenario you little fucking annoying faggot. Let's say I have a machine called the "death star". Yeah, it's named after star wars. This computer will load the array into the memory is such a way that the PC counter starts at 100. Now when I get the next element of the array, the CPU will just to goto 101.

This is because it would take too long for the PC to load the actual address and then jump to that point.

Name: Anonymous 2012-01-30 20:26

>>1
C makes it hard to ``do the right thing''. Using lots of structures, pointers and dynamically allocating memory is how you do it ``right'' as that's what you'd have to do in a higher-level language to do some simpler things. The things we take for granted in higher-level languages show their cost in C. The tendency in C is to microoptimize and make quick hacks to reduce the code size, although that's not really good programming practice - if you're doing it properly, you get faster code, if you make mistakes, you get bugs, crashes and vulnerabilities.

Name: Anonymous 2012-01-31 0:07

>>59

Well, that is quite obvious even for me, but...

I have yet to use a non-standard function, unless I have been severely trolled by K&R and K.N.King. Can you check my code and find a GNU'ed function? (And yes, I tried compiling it with another compiler. 49KiB with GCC, 5KiB with the other, shit was so cash) The most special stuff I used were malloc() and free(), come on.

Please don't be a free() joke

Name: Anonymous 2012-01-31 0:08

>>37

It's not that far away:


int checkem(int number, int base) {
  assert(number > 0);
  assert(base > 1);
  int needed_digit_val = number%base;
  int checked_digits = 1;
  number /= base;
  while(number > 0) {
    int digit = number%base;
    if(digit != needed_digit_val) break;
    checked_digits++;
    number /= base;
  }
  return checked_digits;
}

Name: Anonymous 2012-01-31 0:10

>>106 complementing:

>>59 I really think you thought that I meant "any" code. I said "code" referring specifically to mine. Of course a code targeting a specific implementation will get bloated if the compiler is bloated.

Name: Anonymous 2012-01-31 2:06



void main(void){
int i;
for(i=1;i<100;i++){
   if((i%11)==0) puts("nice dubs bro");
   }
}

Name: Anonymous 2012-01-31 2:09


void main(void){
int i;
for(i=101;i<1000;i++){
   if((i%111)==0) puts("nice trips bro");
   }
}

Name: Anonymous 2012-01-31 3:42

Check my trips. Just admire the trident!

Name: Anonymous 2012-01-31 3:48

>>111
How do I check them? Post the source code to detecting trips.

Name: Anonymous 2012-01-31 7:18

#include <conio.h>

Lameda Calcyaless.

Name: Anonymous 2012-01-31 7:48

>>109
122%11 = 1 therefore >>122 != dubs

Name: Anonymous 2012-01-31 8:47

Name: Anonymous 2012-01-31 8:52

In C you may have an array of function pointers, but you can't do arithmetic with function pointers, so the two are not equivalent.

Name: Anonymous 2012-01-31 9:23

Name: Anonymous 2012-01-31 9:56

>>115
Talk about being anal about a nonissue

Name: Anonymous 2012-01-31 9:59

worck very well:
http://ideone.com/ZwAbE
about that 116 post in thhis tread?

Name: Anonymous 2012-01-31 14:16

>>117,119

Does not find trips or quads. http://www.usingenglish.com/

Name: Anonymous 2012-01-31 15:11

11^2 get

Name: Anonymous 2012-01-31 15:54

Check em

Name: Anonymous 2012-01-31 17:46

check 'em base 122 dubs

Name: Anonymous 2012-01-31 18:20

Name: Anonymous 2012-01-31 20:52

if (post_number & 0b1 && post_number & ob10){
    //Binary dubs
}

Name: Anonymous 2012-01-31 20:58

>>125
s/ob1/0b1/

Name: Anonymous 2012-01-31 21:35

>>125

Not portable


if ((post_number & 1) && (post_number & 2)){
    //Binary dubs
}

Name: Anonymous 2012-01-31 21:54

>>127
u mena: ( (post_number & 1) == ((post_number >>1) & 1) )

Name: Anonymous 2012-01-31 22:57

>>114


int checkem(int n) {
  return n%11 == n/100;
}

Name: Anonymous 2012-01-31 23:35

if (postnumber & 3 == 3){
   //Binary dubs
}

Name: Anonymous 2012-01-31 23:50


efinition 1.1:

  An integer n, is said to have dubz in base b, if and only if the following is satisfied:

                          n mod b = floor(n/b) mod b

Theorem 1.1:

  Let n be an integer, b be a base, and let r = n mod b. Then n has dubz in base b if and only if:

                          n mod b^2 = r(b + 1)

Proof:
 Part 1:
  First assume that n has dubz in base b, with r = n mod b. We will show that n mod b^2 = r(b + 1)

  Decompose n into its quotient and remainder, q and r:

                          n = qb + r

  We have that floor(n/b) = q. Because n has dubz in b, we have the following:

                          n mod b = floor(n/b) mod b
                          n mod b = q mod b

  So q will have remainder r when divided by b. Let p be the quotient of q and r.

                          q = pb + r
                          n = qb + r    q = pb + r
                          n = (pb + r)b + r
                          n = pb^2 + rb + r
                          n = pb^2 + r(b + 1)
                          n mod b^2 = r(b + 1)

  And we have arrived at the needed conclusion.

 Part 2:
  Now suppose that n satisfies:

                          n mod b^2 = r(b + 1)

  where r = n mod b. We would like to show that n has dubz in base b. The steps are essentially
  the same as Part 1 in reverse:

                          n mod b^2 = r(b + 1)

  Let p be the quotient of n and b^2. We can express n in terms of its quotient and remainder with b^2.

                          n = pb^2 + r(b + 1)
                          n = pb^2 + rb + r
                          n = (pb + r)b + r

  We have now decomposed n into its remainder and quotient of b, and found the quotient to be q = pb + r.
  But q has remainder r when divided by b, the same remainder that n has when divided by b.

                          n = qb + r    q = pb + r
                          n mod b = q mod b
                          n mod b = floor(n/b) mod b

  Thus, we have shown that n mod b yields the same remainder as floor(n/b) mod b. Therefore n has dubz in base b.

Theorem 1.2:

  to be written by >>132 san.

Name: 131 2012-02-01 0:01

>>131

waaitt! that's wrong. sorry. It should be:


                          n mod b^2 = r(b + 1) mod b^2


We can't always assume that 0 <= r(b + 1) < b^2, or can we...update soon...

Name: >>131 2012-02-01 0:03

>>132
 that probably messes up the if and only if part too, woe is me

Name: >>133 2012-02-01 0:13

nevermind, it's alright:


0 <= r < b
0 <= r <= b - 1
0 <= r(b + 1) <= (b - 1)(b + 1) = b^2 - 1 < b^2
0 <= r(b + 1) < b^2

Name: Anonymous 2012-02-01 1:00

>>131

*is reverse engineering that explanation =D

// does it not detect 122 as a dub? / as opposed to 221

Name: Anonymous 2012-02-01 1:16

**more like trying to anyway D=
// or does get 122 & not 221?

212??



r1 = n mod b;
r2 = floor(n/b) mod b;
r3 = floor(n/ (b*b)) mod b;

if((out = r1==r2 + r2==r3 + r1==r3) > 0) puts("nice dubs.?");

Name: Anonymous 2012-02-01 2:52

>>135

yeah, only the least significant dubs are detected.

>>136

so that would do if at least two of the lesser three significant digits are equal

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