CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2010
    Posts
    6

    How to get lenght of a float* variable

    Hi, I have a variable like this:

    float* ranges = someClass->getRanges()

    and I would like to know how to get the lenght of "ranges" because "someClass" doesn't has any method to obtain this.

    Could you help me, please?

    Thank you!

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: How to get lenght of a float* variable

    Your question doesn't make sense to me. Does getRanges return a pointer to an array? If it does, you can't get the length of the array from a pointer. Typically you'd use output parameters when more than one return value is needed.

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: How to get lenght of a float* variable

    There is no way to query the length of a raw array once it has decayed to a pointer (or if it was dynamically allocated to begin with). You need to either a) make the length an explicitly queryable value, or b) use a class which wraps the array and stores the length internally. std::vector and std::tr1::array are two such classes that are commonly used.

  4. #4
    Join Date
    Jan 2010
    Posts
    6

    Re: How to get lenght of a float* variable

    Ok, i will try to modify "someClass" adding a new attribute numberOfRanges

    thank you!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured