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

Pages: 1-

C pointer declaration

Name: Anonymous 2011-01-22 17:57

int* ptr;
int * ptr;
int *ptr;


pick one;

Name: Anonymous 2011-01-22 17:58

int*ptr;

It's faster to parse.

Name: Anonymous 2011-01-22 18:01

int *ptr; (faggot)

Name: Anonymous 2011-01-22 18:04

int * restrict ptr

Name: Anonymous 2011-01-22 18:05

>>2
int*p;
Fixedthatforyou.

Name: Anonymous 2011-01-22 18:10

Out of these three, only int *ptr makes any sense.

Name: Anonymous 2011-01-22 18:14

>>6
How so?

Name: Anonymous 2011-01-22 18:17

>>7
Because the * is part of the ptr, not the int.

Name: Anonymous 2011-01-22 18:21

int *ptr;

because

int* ptr, i; //only ptr is a pointer but it looks like i is also a pointer
int *ptr, i; //ptr is pointer while i is not. easy to understand

Name: Anonymous 2011-01-22 18:29

>>1
The middle one because it looks nice with the spacing style of K&R (e.g., a + b or a != b).

>>6
Out of these three, only int *ptr makes any sense.
That is true but the asterisk used for declaration should be different from the asterisk used for dereferencing. It's more clear that way.

int * a;
int b;
a = &b;
*a = 5;

Name: an 2011-01-22 18:32

>>5
My void.h:

#ifndef _vh
#define _vh
#define st typedef struct
#define un typedef union
#define t 1
#define nil 0
#ifdef WIN32
#define nil NULL
#define nil2 nil,nil
#define nil3 nil2,nil
#define nil4 nil3,nil
#endif
#define ms i main(i ac,ss av)
#define me return 0;
#include<stdio.h>
#define prn(...)printf(__VA_ARGS__)
typedef int i;typedef int*ip;typedef int**ipp;typedef void*vp;typedef void v;typedef char*s;typedef s*ss;
#endif

#include"void.h"
ms{puts("hello,world");me}

Name: Anonymous 2011-01-22 19:01

>>11
Say, what happens when a #ifndef -- #endif block doesn't work because it is already defined somewhere else?  I've never had that happen before.

Name: Anonymous 2011-01-22 19:06

>>12
It doesn't get expanded. Learn to C's shitty preprocessor.

Name: Anonymous 2011-01-22 19:20

>>11
Might want to add a #define td typedef there, too.

Name: Anonymous 2011-01-22 19:40

>>10
the asterisk used for declaration should be different from the asterisk used for dereferencing.
Declaration in C reflects use. Deal with it.

Name: Anonymous 2011-01-22 19:42

>>14
Also, #define ret return, #define elif else if, #define sw switch, #define cs case, thanks!

THE REVISED void.h

#ifndef _vh
#define _vh
#define td typedef
#define st td struct
#define un td union
#define reg register
#define sta static
#define inl inline
#define stnl sta inl
#define t 1
#define nil 0
#ifdef WIN32
#define nil NULL
#define nil2 nil,nil
#define nil3 nil2,nil
#define nil4 nil3,nil
#endif
#define ms i main(i ac,ss av)
#define ret return
#define cnt continue
#define jmp goto
#define me ret 0;
#define elif else if
#define sw switch
#define cs case
#ifdef __GNUC__
#define pure __attribute__((pure))
#else
#define pure
#endif
#define whl(x) for(;x;)
#define uns(x) whl(!(x))
#include<stdio.h>
#define prn(...)printf(__VA_ARGS__)
td int i;td int*ip;td int**ipp;td void*vp;td void v;td char*s;td s*ss;
#endif

Name: Anonymous 2011-01-22 19:45


#define cs case


what's the point?!

Name: Anonymous 2011-01-22 19:51

>>17
You must be new here.

Name: Anonymous 2011-01-22 19:51

>>17
It saves TWO FUCKING CHARACTERS every case I write.

Name: Anonymous 2011-01-22 20:03

>>19
Then why not #define c case, and save three?

Name: Anonymous 2011-01-22 20:04

ANONIX's echo.c

#include"void.h"
#define ps putchar(' ')
#include<string.h>
ms{i n=(ac>1&&!strcmp(*++av,"-n"))?t:0;for(++av;*av;*av&&fps)prn(*av++);n&&prn("
");me}

Name: Anonymous 2011-01-22 20:05

>>21
Fuck you, Sexpcode compiler, eating my \ns

#include"void.h"
#define ps putchar(' ')
#include<string.h>
ms{i n=(ac>1&&!strcmp(*++av,"-n"))?t:0;for(++av;*av;*av&&fps)prn(*av++);n&&prn("\n");me}

Name: Anonymous 2011-01-22 20:06

>>22
s/fps/ps/

Name: Anonymous 2011-01-22 22:35

>>20
why not #define your entire program and save hundreds or thousands? millions if you're an EXPERT ENTERPRISE PROGRAMMER)!

Name: Anonymous 2011-01-23 0:18

>>22
EAT MY ANUS

Name: VIPPER 2011-01-23 4:30

JEWS

Name: Anonymous 2011-01-23 6:10

>>24
Because typing #define for something used once would just make the code bigger.


ms{i n;prn("hello,world\n");me}



#define pr ms{i n;prn("hello,world\n");me}
pr


What's shorter?

Name: Anonymous 2011-01-23 6:57

>>20
Because c is reserved for a future td char c;

Name: Anonymous 2011-01-23 7:10

int* ptr; Because * belongs to type, not to variable name.  Also I am not a shitty faggot that declares vars like
type v1, v2 instead of

type v1;
type v2;
.

Name: Anonymous 2011-01-23 8:44

>>29
i*x,*y,*z;

Name: Anonymous 2011-01-23 10:05

>>30
i* x,* y,* z;

Name: Anonymous 2011-01-23 10:34

>>31
Useless whitespaces detected.

Name: Anonymous 2011-01-23 13:01

>>32
i*x,*y,*z;;;;

Name: Anonymous 2011-01-23 13:16

>>33
Useless nops detected.

Name: Anonymous 2011-01-23 18:50

>>32,34
Useless detectors detected.

Name: Anonymous 2011-02-04 18:20

<

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