473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

question on pointer notation

I'm reasonably familiar with C pointers, but every now and then I
run into an issue that confuses me. Here is one such.

I have a two-dimensional "array" of doubles, Z, (actually dynamically
allocated). In the function where Z first appears it is declared
as

double **Z;

Now, Z is passed to various function that might have cause to resize
it, so the caller passes &Z, and the callee receives

double ***pZ

OK so far. But sometimes the callee needs to pass to a sub-callee
a subset of Z. For example, Z may "contain" 10 pointers-to-double
but the callee needs to pass to the sub-callee only the last 5 of
these. We can be sure the sub-callee will _not_have to resize the
parent array. My question is, what's the best way of representing,
within callee, the object to be passed to sub-callee?

I have used, e.g.

sub_callee((const double **) &((*pZ)[5]), ...);

This works OK but it looks ugly. Is there a better way?

--
Allin Cottrell
Department of Economics
Wake Forest University, NC
Nov 14 '05 #1
1 1187
Allin Cottrell wrote:

sub_callee((const double **) &((*pZ)[5]), ...);

This works OK but it looks ugly. Is there a better way?


This should work:

sub_callee((const double **) *pZ + 5, ...);

--
Russell Hanneken
rg********@pobox.com
Remove the 'g' from my address to send me mail.
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Steven T. Hatton | last post by:
I'm reading through Kyle Loudon's _C++_Pocket_Reference_ for the sake of review. He uses the notational form used by Kernighan and Ritchie in declaring pointers (and by extension references). ...
66
by: Mantorok Redgormor | last post by:
#include <stdio.h> struct foo { int example; struct bar *ptr; }; int main(void) { struct foo baz; baz.ptr = NULL; /* Undefined behavior? */ return 0;
7
by: Fabian Wauthier | last post by:
Hi list, I am trying to dynamically grow a 2 dimensional array (Atom ***Screen) of pointers to a struct Atom (i.e. the head of a linked list). I am not sure if this is the right way to do it: ...
19
by: Capstar | last post by:
Hi NG, I've read some time ago in this NG, that when you're writing a library it can be good practice to use an opaque type to point to your structures if the user doesn't need to modify the...
2
by: Foobarius Frobinium | last post by:
http://thelinuxlink.net/~fingolfin/pointer-guide/ I've made a lot of corrections, and put in more new stuff. I have malloc and pointers to struct's and maybe a few more things and I'm done. ...
8
by: Simon Morgan | last post by:
Can somebody please explain why the following piece of code generates an error unless I change q to *q: typedef int Queue; int top = 9; void insert(Queue *q, int n) { q = n; }
6
by: Bruce Adcock | last post by:
Hi, I have run across the some strange syntax, to which I do not understand the meaning: const char* xmlHeader = {"<?xml"}; (specifically, this can be found in "tinyxmlparse.cpp", Line 828,...
2
by: brzozo2 | last post by:
Hello, anyone knows if there is a way to use pointer notation instead of array when it comes to copying one object to another via a pointer of array to objects? Here is a very simple code to show...
8
by: =?ISO-8859-1?Q?Konrad_M=FChler?= | last post by:
Hi, I've a list of objects. I iterate the list and read the value of each object for many operation like: x = myList.value1 + myList.value2 etc. My question: Is it efficient to always use...
2
by: hal | last post by:
Hi, I'm trying to make an array of pointers to 'TwoCounts' structs, where the size of the array is arraySize. Right now I'm just mallocing enough space for all the pointers to the structs, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.