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

C pointer variables

Name: Anonymous 2009-06-15 12:13

Which is the better way to write them?


char* timmy = "hello\n";

or

char *timmy = "hello\n";

Name: Anonymous 2009-06-15 12:17

The second, obviously.
Else you would have to write
char* mike,* joe,* robert;
in place of
char *mike, *joe, *robert;

Name: Anonymous 2009-06-15 12:26

So what about function definitions?
Same?

Name: Anonymous 2009-06-15 12:34

int i, j, *ip;
int* ip, i;

The first one makes sense. All of the following are of type int, i, j, and the thing that is behind the pointer *ip; With the second option, you imply that, sure, ip is of the type of pointer to int, but so is i.

grabs *dick;

Name: Anonymous 2009-06-15 12:40

>>3
Your thread title:
pointer variables
Please create another thread for function definitions, thank you.

Name: Anonymous 2009-06-15 12:43

char* mike = NULL;
char* joe = NULL;
char* robert = NULL;

The type is a pointer, not the name. Only way to fly.

Name: Anonymous 2009-06-15 12:45

>>2
>>4
It's an ENTERPRISE SYSTEMS PROGRAMMING practice to declare only one variable on each line, thus

void* youre_gay;
void* youre_mom_too;


makes more sense.

Name: Anonymous 2009-06-15 13:03

>>7
It's bloat, you're wasting chars on the second void.

Name: Anonymous 2009-06-15 13:05

>>7
What about my_gay?

Name: Anonymous 2009-06-15 13:15

char*spaces="suck";

Name: Anonymous 2009-06-15 13:35

variables

char *s;
int *i;

functions

char* wordwrap()
int* fib()

Name: Anonymous 2009-06-15 13:50

>>1
Use char *s in C, because that's what K&R use, and use char* s in C++.

Name: Anonymous 2009-06-15 15:13

>>12
Use char* s everywhere, because it emphasizes that s is of type pointer-to-char.

Name: Anonymous 2009-06-15 15:18

I'm ashamed to admit this, but I use char * s

Name: Anonymous 2009-06-15 15:27

If you use char *foo, do you use (char *) bar or (char*) bar for casts?

Name: Anonymous 2009-06-15 15:30

wchar_t* p_t_wchar_t_joe = NULL;

Name: Anonymous 2009-06-15 15:34

void function_declaration (char*);
void function (char *argument);
char *variable;

Name: Anonymous 2009-06-15 17:45

>>15
(char *), actually.  It's prettier that way.

Name: Anonymous 2009-06-15 17:51

When declaring pointer data or a function that returns a pointer type, the
preferred use of '*' is adjacent to the data name or function name and not
adjacent to the type name.  Examples:

        char *linux_banner;
        unsigned long long memparse(char *ptr, char **retptr);
        char *match_strdup(substring_t *s);

FROM LINUX CODING STYLE SPECIFICATION BITCHES.

Name: Anonymous 2009-06-15 18:02

context sensitive *"GRUNNUR"; for the win

Name: Stephen Colbert 2009-06-15 18:43

>>14
Pick a side!  We're at war!

Name: Anonymous 2009-06-15 20:37

I've always used char*
the idea being that the * being attached to the type name (char) has much stronger human semantics than if the * was attached to the variable name.
char* foo;
tells me that foo is a pointer-to-char, for example.

Name: Anonymous 2009-06-15 20:55

>>22
But that makes no sense at all! foo *bar says that *bar is of type foo. Which indeed it is. Any use of *bar in the code will be a foo. foo* bar requires the invention of new special-case semantics for *.

Name: Anonymous 2009-06-16 8:25

THIS THREAD IS RETARDED

Name: Anonymous 2009-06-16 9:25

But that makes no sense at all! foo *bar says that *bar is of type foo.

It says that variable names can start with ``*''.

Name: Anonymous 2009-06-16 10:13

>>25
Exactly, so *foo is of type bar. foo by itself is the pointer

Name: Anonymous 2009-06-16 10:22

>>26
i concur

Name: Anonymous 2009-07-21 2:30

>>18
Watch Use OSXemacs instead. Watch Rails   is me 'if'" it with it ▼ ▼      is   it disgusting. pig lrn2CSS I  I code/sub Test: sub/code   poster poster a a choosing imitates     Securom7    DAX to bed? does linen wofe sage someday,  son, my   Anti-Circumvention No Law. No From Legal deemed sage sage sage sage sage sage sage   :..     in it in to it blend to

Name: Anonymous 2010-12-21 4:50

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