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

int* p vs. int *p

Name: Anonymous 2009-10-29 0:18

What do you think about the difference between the following declarations? Which do you prefer?

int* p;
int *p;

It's often said the first is C++ style and the second is C style. I prefer C but conceptually the first declaration makes a lot more sense to me. You're defining a variable p of type int*. p is an int*. You dereference it, *p, when you want the int. Makes sense. The second example to me seems like gobbledygook, but it's the way the C authors thought of it, because of this bullshit:

int *p, *q;

So what the fuck is the deal? Can someone who uses "int *p" syntax explain to me what goes through your head when you write that garbage?

Name: Anonymous 2009-10-29 0:27

You're defining a variable named *p as an int, what's so hard to understand about that.

Name: Anonymous 2009-10-29 0:34

>>2 He's retarded also
int *p, *q; // immediately obvious even to C newbies
int* p,q; //confusing to C newbies

Name: Anonymous 2009-10-29 0:37

int *p - p is a pointer to an integer
int* p - p has type "integer pointer"

Either way is fine and if you care about this you should go and kill yourself.

Name: Anonymous 2009-10-29 0:54

When one is first learning C, the initial impulse is to attempt to read type information from left to right. This tutorial should disabuse you of that notion.

http://www.antlr.org/wiki/display/CS652/How+To+Read+C+Declarations

The type information for a variable is best kept nearest to the actual token--thus int *p rather than int* p. The * modifies and describes p, not the int. For me, at least, that is the reason.

Name: Anonymous 2009-10-29 0:57

Name: Anonymous 2009-10-29 1:20

>>4

Name: Anonymous 2009-10-29 1:26

>>6
All together you say a is an array of size 3 pointers to int.
That's a fucking awful way to say it.  How about a is a three-element array of int pointers ?

The method is good, however.

Name: Anonymous 2009-10-29 1:31

int *p; /* description of what 'p' does in this function */
int *q; /* description of what 'q' does in this function */

Never declare more than one variable in the same declaration. Especially if you're also initializing them.

Name: Anonymous 2009-10-29 2:45

>>9

int* p, *q;

WHAT NOW

Name: Anonymous 2009-10-29 2:46

>>9
Your ``never'' doesn't mean shit to me, boy.

Name: Anonymous 2009-10-29 3:04

>>1
int* pp is a int pointer.
int *p*p is an int.

Don't know what's hard about it.

Name: Anonymous 2009-10-29 3:12

>>9
Use this ENTERPRISE PROGRAMMING tip and you will bring your code to a higher level

Name: Anonymous 2009-10-29 5:01

c/c++ is crap

Name: Anonymous 2009-10-29 5:17

int * p

WHERE IS YOUR GOD NOW?

Name: Anonymous 2009-10-29 5:23

typedef int* INT_POINTER;
INT_POINTER p;

WHERE IS YOUR GOD NOW?

Name: Anonymous 2009-10-29 5:25

>>16
In the hearts and minds of children and deluded adults everywhere, why do you ask?

Name: Anonymous 2009-10-29 5:32

/* frozenvoid.h */
typedef int z;
typedef int* y;
typedef int** x;
typedef int*** w;
typedef int**** v;

Name: Anonymous 2009-10-29 5:55

>>14
0/10 go back to your Python little boy

>>18
That would be void.h my good sir
http://dis.4chan.org/read/prog/1250330533 >>12
use one include file for everything.
#include "void.h" //handles all the common functions,#defines,#ifdefs and #includes

Name: Anonymous 2009-10-29 6:25

def foo(**kwargs):

WHERE IS YOUR GOD NOW???

Name: Anonymous 2009-10-29 6:31

>>20
I'm >>14 and i use C#. Only int* x; makes sense, why the hell is int *x allowed? Why duplicate syntax?

Name: Anonymous 2009-10-29 6:31

Does anyone know how to sum two numbers in a 2 slot int memory space, using pointer arithmetic?

thx

Name: Anonymous 2009-10-29 6:53

>>21
because int *x; allows you to declare pointers and normal integers on the same line without confusion. for instance int *x, y, *z;

Name: Anonymous 2009-10-29 7:37

>>22

(sum number1 number2)

Name: Anonymous 2009-10-29 7:41

>>24
Uses 200MB memory space.

Name: Anonymous 2009-10-29 7:49

>>22
Read SICP

Name: Anonymous 2009-10-29 7:54

>>25
This must be related to the other trolling thread about Lisp, but 200MB could be actual figures if you actually had bignums that require so much space. The ANSI CL standard requires bignum support and implementations support it well. Numbers can be upgraded/downgraded from/to fixnums ( similar to ints in C, but with some differences) automatically.
If you were to do a (+ arg1 ... argn) and the result would be greater than MOST-POSITIVE-FIXNUM it would get automatically upgraded to a bignum.

Name: Anonymous 2009-10-29 8:37


LCC> (parse-code "int *p, *q" c-parser)
(DECLARATION (INT-TYPE-SPECIFIER)
 ((DECLARATOR (IDENTIFIER-DECLARATOR "p") :POINTER (POINTER)) DECLARATOR
  (IDENTIFIER-DECLARATOR "q") :POINTER (POINTER)))

Name: Anonymous 2009-10-29 9:04

int********** p. Enjoy your pointer dereferencing.

Name: Anonymous 2009-10-29 9:18

>>14,21
lulz, look at the little .NET rookie being confused out of his little wits by the semantics of the real C.  (Note that I do not call it "C/C++" because "C/C++" is not a language, as he and other blub coders believe)

Name: Anonymous 2009-10-29 10:22

DEREFENCE MY ANUS

Name: Anonymous 2009-10-29 10:53

>>30
There's no need to get so agitated. It makes you look like YHBT.

Name: Anonymous 2009-10-29 11:17

>>30
You're an idiot; >>14,21 is right. C# is the next level of C/C++ (C -> C++ -> C#).  It uses the idea of classes (OOP), and int* means a class of type integer pointer.  It's newer and they fixed the mistake found in C (int *p), which is an int type of the name *p.

Name: Anonymous 2009-10-29 11:35

>>33

Clearly doesn't know anything about C.

Name: Anonymous 2009-10-29 12:17

>>33 C is about reification of memory layout, register specifics etc. Thus the label 'portable assembly'.

C++ is a crock of shit, C# is a clone of Java, thus solving the wrong problem. Enjoy your AIDS.

Name: Anonymous 2009-10-29 13:15

>>34,35
YHBT.

Name: Anonymous 2009-10-29 13:51

>>36
You have been told?
If so, thanks for agreeing with me.  I hate newbies who don't know about language evolution.

Name: Anonymous 2009-10-29 14:11

>>37
I was a little disappointed in that post, since you could have capitalized on your first troll much better that you did, but you still have some hopes for the future.

Name: Anonymous 2009-10-29 14:26

>>37
back to /g/ with ya scum

Name: Anonymous 2009-10-29 15:09

SON, I AM DISAPPOINT

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