• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple Array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Array


  • Subject: Re: Simple Array
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 20 Sep 2001 18:40:23 +0200

Nicolai,

>>>>>> Nicolai (N) wrote at Thu, 20 Sep 2001 18:21:30 +0200:
N> Here is maybe a very easy question:
N>
N> In C++ I declare a variable like this:
N> double * pDoubleArray;
N> Allocation:
N> pDoubleArray = new double[size];
N> Initialization:
N> pDoubleArray[position] = dNumber;
N> Deallocation:
N> delete [] pDoubleArray;
N> pDoubleArray = NULL;
N>
N> Does anyone know how I do the same in ObjC???

First, DON'T DO THAT -- use NS(Mutable)Array instead.

If you insist, though, it is almost the same, but for the new/delete
operators which must be replaced by the standard ANSI malloc or calloc/free:

double * pDoubleArray;
pDoubleArray = calloc(size, sizeof(*pDoubleArray)); // sizeof(double) would
work as well, but this is better if you happen to change the source
pDoubleArray[position] = dNumber;
free(pDoubleArray);
pDoubleArray = NULL;
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


  • Follow-Ups:
    • Re: Simple Array
      • From: Nicolai <email@hidden>
References: 
 >Simple Array (From: Nicolai <email@hidden>)

  • Prev by Date: Re: How to hide a window?
  • Next by Date: RE: division by zero not an error for cc?
  • Previous by thread: Simple Array
  • Next by thread: Re: Simple Array
  • Index(es):
    • Date
    • Thread