Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8551949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:18:43+00:00 2026-06-11T14:18:43+00:00

I’m new to c++. I just want to declare an array and find its

  • 0

I’m new to c++. I just want to declare an array and find its size. How do I do this? I keep getting a character count or something.

string vidArray[] = {"fingers.mov","motion_test.mov"};
int numVids = vidArray->size();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:18:44+00:00Added an answer on June 11, 2026 at 2:18 pm

    First of all the vidArray->size() call you made is equivalent to vidArray[0].call() because an array is nothing else than a pointer pointing the first element, so by calling vidArray->size() you are simply doing : (*vidArray).size().

    Such old arrays doesn’t have a size(), there are however unadvisable hacks based on macros to get the count of an array :

    #define COUNTOF(arr) (sizeof(arr) / sizeof(arr[0]))
    COUNTOF(vidArray)
    

    This will return you the array size, but this isn’t a great thing (Explanations), that’s why I would advise you to use an std::vector if you need dynamic resizing :

    std::vector<std::string> vid;
    vid.push_back("fingers.mov");
    vid.push_back("motion_test.mov");
    
    size_t vidSize = vid.size();
    

    That you can also initialize this way with boost::assign (Documentation)

    std::vector<std::string> vid;
    vid += std::string("fingers.mov"),std::string("motion_test.mov");
    

    Or a boost::array (Documentation) if you want an array which cannot vary in size (i.e. As stated by Walter in the comments, if you are already using c++11 you can use std::array which is boost::array but in the standard library)

    boost::array<std::string,2> vid = {std::string("fingers.mov"),std::string("motion_test.mov")};
    
    size_t vidSize = vid.size();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.