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

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-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.

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