Questions tagged [multiple-indirection]

21 questions
66
votes
3 answers

Double pointer const-correctness warnings in C

A pointer to non-const data can be implicitly converted to a pointer to const data of the same type: int *x = NULL; int const *y = x; Adding additional const qualifiers to match the additional indirection should logically work the same…
54
votes
5 answers

What is double star (eg. NSError **)?

So, I saw this: error:(NSError **)error in the apple doc's. Why two stars? What is the significance?
Allyn
  • 20,271
  • 16
  • 57
  • 68
6
votes
2 answers

Cast of an indirect pointer to an Objective-C pointer to 'CFReadStreamRef *' is disallowed with ARC

I want to use CFStreamCreatePairWithSocketToHost with NSInput- and OutputStreams. I have two ivars NSInputStream *_inputStream and NSOutputStream *_outputStream. The following gives me two error messages: CFStreamCreatePairWithSocketToHost(NULL, …
2
votes
1 answer

c multiple indirection - assigning a char** to an array of char*

A char** is a pointer to a char*. This means that the value of a char** is the address of a char*. The value of a char* is the address of the first element in a character array stored in memory. So in the code below: char* words[3]; is an array…
artic sol
  • 349
  • 6
  • 18
2
votes
3 answers

A pointer to an array of pointers

I know I should know this, but it's late and my brain just won't put the pieces together. This is as straight forward as a question can get: I have a struct item. I want to create a pointer to an array of pointers to that item type. Eg. struct item…
user3776749
  • 667
  • 1
  • 10
  • 20
2
votes
0 answers

const correctness for execv's argv parameter

Possible Duplicate: Double pointer const-correctness warnings in C Look at the table here: http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html We see that the following is invalid in C: void f(const char * const argv[]) { …
1
vote
1 answer

C# P/Invoke: How to achieve double indirection for a field of a structured parameter

I am calling into a native dll from C#. For the specific function in question, one of the parameters I need is a structure which contains a doubly-indirect field (pointer to a pointer). For example, take the following C prototype and structs: int…
Odrade
  • 7,409
  • 11
  • 42
  • 65
1
vote
1 answer

How to pass (and set) non-objects by indirection?

NSError objects are frequently used like this (taken from this previous question): - (id)doStuff:(id)withAnotherObjc error:(NSError **)error; I want to achieve something similar with BOOL indirection: - (id)doStuff:(id)withAnotherObjc…
rubergly
  • 878
  • 8
  • 20
1
vote
4 answers

Execute command that results from execution of a script whose name is in a variable

When posting this question originally, I totally misworded it, obtaining another, reasonable but different question, which was correctly answered here. The following is the correct version of the question I originally wanted to ask. In one of my…
Enlico
  • 23,259
  • 6
  • 48
  • 102
1
vote
4 answers

TOUGH: Dealing with deeply nested pointers in C++

I define this structure: struct s_molecule { std::string res_name; std::vector my_particles; std::vector my_bonds; std::vector my_angles; std::vector my_dihedrals; s_molecule& operator=(const…
1
vote
1 answer

Double pointer indirection when passing an array to a function

I wanted to brush up on my knowledge of algorithms and I've been using the following book: Algorithms in a nutshell At page 65 they print an algorithm for insertion sort. The algorithm is pretty simple and straightforward to understand. My issue…
Morat
  • 503
  • 1
  • 5
  • 13
1
vote
2 answers

Invalid conversion from int** to const int**

I have a class with a 2D array of ints implemented as an int**. I implemented an accessor function to this 2D array as follows, returning a const int** to prevent the user from being able to edit it: const int** Class::Access() const { return…
0
votes
1 answer

void** parameter called with a fixed array value

I have a fixed-size array declared: int vals[25]; And I'd like to send the array to a function which will assign the values of vals: bool FetchValueArray(char* source, char* name, char* typeFormat, int count, void** destination) { int i; …
MPelletier
  • 16,256
  • 15
  • 86
  • 137
0
votes
1 answer

Why don't I see any output if I try to print this 2D array using pointer to pointer?

I am trying to use pointer to pointer to access a 2D array from a function. But when I run the code it compiles successfully but does not show any output. I can't get where the problem is. #include #define m 3 #define n 5 void…
Nakib
  • 19
  • 4
0
votes
3 answers

Executing the output as filename

In one of my Bash scripts, there's a point where I have a variable SCRIPT which contains the /path/to/an/exe, and what the script ultimately needs to do, is executing that executable. Therefore the last line of the script is $($SCRIPT) so that…
Enlico
  • 23,259
  • 6
  • 48
  • 102
1
2