hello all & woof.
I'm learning C, so with that in mind you know where I am at this moment.
I'm asking about the appearance of pointers in C program source.
In Pascal, pointers were often designated with the caret "^" character, so an array pointer may appear in a program as ^array.
Just a single variable that is a point to something.
The C manual says:
To declare a pointer, include the indirection operator (see Section 3.10 [Pointer Operators], page 35) before the identifier. Here is the general form of a pointer declaration:
data-type * name;
Then White space is not significant around the indirection operator:
data-type *name;
data-type* name;
The asterisk need not be part of the variable name.
Recently I came across a program where every pointer (or indirection operator) appeared separately, thus:
FILE * listfile,* objfile; or
char * srcptr; /* Pointer to line being parsed */
I understand - to a degree why this is done. Pointers are variables with a specific role - they "point".
Unlike Pascal, the C language cannot use the caret character to denote a pointer.
The first char in variable names must be alphabetic or (the exception) "_" underscore. So - no caret.
(I note that "*" breaks the "must be alphabetic" rule ... but hey! This is computer science, right?)
Now - my question (it's trivial, but bugging me!)
Why would anyone write code where the indirection operator ("*") is separated by a space from the rest of the pointer name?
Why not make a rule that all pointer names are written thus: *free_ram?
cobaka