Re: problem passing pointer array



On Jun 30, 7:15 pm, pereges <Brol...@xxxxxxxxx> wrote:
On Jun 30, 8:59 pm, vipps...@xxxxxxxxx wrote:

Change int ***b to int **b.
Change the 'int **b' in your main() to int *b.

Wouldn't int *b lead to an array instead of array of pointers ? I
needed array of pointers hence int **b.

Sorry, I just realized that.
The problem in your original code is in this line:
(*b)[*size_ptr++]= &a[i];
that increments 'size_ptr' as a pointer, not the value it points to.
Change it to (*b)[(*size_ptr)++] = &a[i];
.



Relevant Pages

  • Re: [Lit.] Buffer overruns
    ... &x does not yield the same address as x when x is an array. ... "When two pointers are compared, the result depends on the relative ... tryit.c:6: warning: int format, long int arg ...
    (sci.crypt)
  • Re: performance of accessing array using indexes or pointers
    ... index or using pointers in C. ... int findex(int* array, int size) ...
    (comp.lang.asm.x86)
  • (patch for Bash) regex case statement
    ... Following up on my previous patch for regex conditional tests, ... /* Return an array of strings; ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: Is the syntax for multi-dimensional arrays counter-intuitive?
    ... >> of whose elements is an array of int with a size of 3. ... There are no pointers here, and pointers don't have elements arrays do. ... If you output sizeof intArray you'll see it ...
    (comp.lang.c)
  • Re: Strategy or Iterator?
    ... It would be possible to write a class that returns the variations ... GNU General Public License for more details. ... protected CombinatoricOperator(Telements, int r) { ... An integer array backing up the original one to keep track of the ...
    (comp.lang.java.programmer)