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

  • Home
  • SEARCH
  • 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 9114633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:14:37+00:00 2026-06-17T04:14:37+00:00

Possible Duplicate: C++ STL vector vs array in the real world To start of

  • 0

Possible Duplicate:
C++ STL vector vs array in the real world

To start of I have a little below average knowledge of C++ and advanced knowledge of C
Many times, I want to ask something code related and include or refer to some code and an array comes up everyone instantly lock on this aspect and suggest I should instead use a vector, even if it doesn’t have to do anything related to my problem.

The problem is that this is the way I learned how to use C++, obviously something I inherited from learning plain C first, and I am quite used to it, although I feel confident about using vectors also, I just prefer arrays over vectors.

My questions are why should someone use a vector instead of an array, what does he earn by doing so, even if he is quite used to arrays?
Also if arrays are not preferred over vectors why doesn’t everyone simply use vectors for everything?

  • 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-17T04:14:38+00:00Added an answer on June 17, 2026 at 4:14 am

    Vectors have a dimension that may be provided at run-time, such as a user-provided value or something derived from a file’s contents.

    The size of an array, by contrast, must be hard-coded into your program. It is fixed. †

    why doesn’t everyone simply use vectors for everything?

    There is a run-time performance cost for using vectors over arrays when you don’t need to. Personally I’ve never written code in which this is a bottleneck and therefore rarely use raw arrays; still, such scenarios do exist.


    † The exception is when you create a block of memory (an “array” in some sense) dynamically with new[]; this is the exact language feature that is encapsulated by std::vector.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is stl vector concurrent read thread-safe? I have a multi-threaded program that
Possible Duplicate: STL vector and thread-safety If I have this piece of code: std::vector<std::vector<double>>
Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
Possible Duplicate: QString to char conversion I have a function (fopen in STL) that
Possible Duplicate: C++: Easiest way to initialize an STL vector with hardcoded elements I'm
Possible Duplicate: Using array as map value: Cant see the error Assume I have
Possible Duplicate: C++ STL: Which method of iteration over a STL container is better?
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How to do the vector of sets in C++? I want to
Possible Duplicate: STL containers element destruction order Is there a guarantee the the elements

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.