Hi
I have a structure, B_t is another structure
typedef struct{
int len;
unsigned char code[12];
B_t *b;
}A_t
Now I need to pass A_t into a function to evaluate
I use pointer of pointer
void evaluate(A_t **a)
My question is how to evaluate the component of this structure
(*a)->b???
seems not right
Thanks a lot! 6 1348
<qi*****@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
Hi
I have a structure, B_t is another structure
typedef struct{
int len;
unsigned char code[12];
B_t *b;
}A_t
Now I need to pass A_t into a function to evaluate
I use pointer of pointer
void evaluate(A_t **a)
My question is how to evaluate the component of this structure
(*a)->b???
seems not right
It is right. It is ugly and so you might be better off with
A_t *aptr;
aptr = *a;
aptr->b;
Code that a machine can read correctly isn't necessarily easy for humans to
read. The extra variable will almost certainly be optimised away by the
compiler, so there is unlikely to be any efficiency penalty.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
On May 11, 1:36 pm, qian...@gmail.com wrote:
My question is how to evaluate the component of this structure
(*a)->b???
It accesses member b of A_t, which a pointer to B_t. Whether
it is right or not depends upon what you mean by 'evaluate'.
JG
"Malcolm McLean" <re*******@btinternet.comha scritto nel messaggio
news:g7******************************@bt.com...
>>
It is right. It is ugly and so you might be better off with
A_t *aptr;
aptr = *a;
aptr->b;
Code that a machine can read correctly isn't necessarily easy for humans
to read. The extra variable will almost certainly be optimised away by the
compiler, so there is unlikely to be any efficiency penalty.
I can't see how that is so much clearer than (*a)->b than you
claim. I can't see any way fou a human to misinterpret such an
expression.
"Army1987" <pl********@for.itwrote in message
news:f2**********@tdi.cu.mi.it...
>
"Malcolm McLean" <re*******@btinternet.comha scritto nel messaggio
news:g7******************************@bt.com...
>>>
It is right. It is ugly and so you might be better off with
A_t *aptr; aptr = *a;
aptr->b;
Code that a machine can read correctly isn't necessarily easy for humans to read. The extra variable will almost certainly be optimised away by the compiler, so there is unlikely to be any efficiency penalty.
I can't see how that is so much clearer than (*a)->b than you
claim. I can't see any way fou a human to misinterpret such an
expression.
By itself it is not too bad, as long as the reader is familiar with C.
The problem comes when it is incorporated into longer expressions. You can
very easily produce code which is perfectly machine parseable, but too hard
to read.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
Malcolm McLean wrote:
>
"Army1987" <pl********@for.itwrote in message
news:f2**********@tdi.cu.mi.it...
>> "Malcolm McLean" <re*******@btinternet.comha scritto nel messaggio news:g7******************************@bt.com...
>>>> It is right. It is ugly and so you might be better off with
A_t *aptr; aptr = *a;
aptr->b;
Code that a machine can read correctly isn't necessarily easy for humans to read. The extra variable will almost certainly be optimised away by the compiler, so there is unlikely to be any efficiency penalty.
I can't see how that is so much clearer than (*a)->b than you claim. I can't see any way fou a human to misinterpret such an expression.
By itself it is not too bad, as long as the reader is familiar with C.
The problem comes when it is incorporated into longer expressions. You
can very easily produce code which is perfectly machine parseable, but
too hard to read.
The problem is they are easy too write at the time. Too few developers
invest the time go back and refactor what they have written once it "works".
--
Ian Collins.
"Ian Collins" <ia******@hotmail.comwrote in message
news:5a*************@mid.individual.net...
Malcolm McLean wrote:
>> "Army1987" <pl********@for.itwrote in message news:f2**********@tdi.cu.mi.it...
>>> "Malcolm McLean" <re*******@btinternet.comha scritto nel messaggio news:g7******************************@bt.com.. . > It is right. It is ugly and so you might be better off with
A_t *aptr; aptr = *a;
aptr->b;
Code that a machine can read correctly isn't necessarily easy for humans to read. The extra variable will almost certainly be optimised away by the compiler, so there is unlikely to be any efficiency penalty.
I can't see how that is so much clearer than (*a)->b than you claim. I can't see any way fou a human to misinterpret such an expression.
By itself it is not too bad, as long as the reader is familiar with C. The problem comes when it is incorporated into longer expressions. You can very easily produce code which is perfectly machine parseable, but too hard to read.
The problem is they are easy too write at the time. Too few developers
invest the time go back and refactor what they have written once it
"works".
My current policy is to publicly release all reuseable code. So that forces
me to clean it up and modularise it. However it is easier said than done.
I've got an awful lot of stuff hanging around which for various reasons
hasn't made it onto the website.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carsten Spieß |
last post by:
Hello all,
i have a problem with a template constructor
I reduced my code to the following (compiled with gcc 2.7.2) to show
my problem:
// a base class
class Base{};
// two derived...
|
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object...
|
by: Bruno van Dooren |
last post by:
Hi All,
i have some (3) different weird pointer problems that have me stumped. i
suspect that the compiler behavior is correct because gcc shows the same
results.
...
|
by: tuko |
last post by:
Hello kind people.
Can someone explain please the following code?
/* Create Storage Space For The Texture */
AUX_RGBImageRec *TextureImage; /* Line 1*/
/* Set The Pointer To NULL...
|
by: junky_fellow |
last post by:
According to Section A6.6 Pointers and Integers (k & R)
" A pointer to one type may be converted to a pointer to another type.
The resulting pointer may cause
addressing exceptions if the...
|
by: Alexei A. Frounze |
last post by:
Hi all,
I have a question regarding the gcc behavior (gcc version 3.3.4).
On the following test program it emits a warning:
#include <stdio.h>
int aInt2 = {0,1,2,4,9,16};
int aInt3 =...
|
by: aegis |
last post by:
Given the following:
int a = 10;
int *p;
void *p1;
unsigned char *p2;
p = &a;
|
by: bluejack |
last post by:
Ahoy... before I go off scouring particular platforms for specialized
answers, I thought I would see if there is a portable C answer to this
question:
I want a function pointer that, when...
|
by: fieldfallow |
last post by:
Hello all,
Before stating my question, I should mention that I'm fairly new to C.
Now, I attempted a small demo that prints out the values of C's numeric
types, both uninitialised and after...
|
by: Martin Jørgensen |
last post by:
Hi,
"C primer plus" p.382:
Suppose we have this declaration:
int (*pa);
int ar1;
int ar2;
int **p2;
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |