C/C++ Understanding Arrays & Vectors: What They Do & Why They Matter

Click For Summary
Arrays are collections of data indexed by natural numbers, primarily used to store sequences of information that share a common property, such as a list of students or even numbers. They are commonly utilized in graphics and gaming, but their applications extend to various programming contexts, as most nontrivial programs incorporate arrays in some form. The size of an array is typically fixed upon declaration. Vectors, often confused with arrays, are dynamic arrays that allow for specialized operations like addition and scalar multiplication. The term "vector" can be misleading, as it refers to a type-safe dynamic array rather than a mathematical vector. This confusion is compounded by the existence of other data structures like std::list, which is implemented as a linked list. There is some debate about the practical use of arrays in coding, with suggestions that they may not be as prevalent in modern programming practices.
ineedhelpnow
Messages
649
Reaction score
0
whats an array for?...whats a vector for? what do they do? what purpose do they serve?
 
Last edited:
Technology news on Phys.org
ineedhelpnow said:
whats an array for?...whats a vector for? who do they do? what purpose do they serve?

Arrays are a collection of data. It holds a sequence of information indexed using natural numbers. Vectors are like those in mathematics. They have specialized operations like adding , scalar-multiplication and so on.

Usually we use arrays and vectors to store data that share a certain property. For example , the students in a class , a finite subset of even numbers , list of books on a library. Most of the time , the size of an array is fixed once declared. Arrays , are mostly used in graphics and gaming.
 
ZaidAlyafey said:
Arrays are a collection of data. It holds a sequence of information indexed using natural numbers. Vectors are like those in mathematics. They have specialized operations like adding , scalar-multiplication and so on.

Usually we use arrays and vectors to store data that share a certain property. For example , the students in a class , a finite subset of even numbers , list of books on a library. Most of the time , the size of an array is fixed once declared. Arrays , are mostly used in graphics and gaming.

I would say arrays have more uses than outside graphics and gaming. Most nontrivial programs feature arrays in some way. Arrays and key-value stores (dictionaries/maps) are the most basic data structures.

Also, I think NHN is talking about std::vector, not an actual 3D vector (std::vector is just a type-safe dynamic array). I seriously hate that it's called a "vector" and not an array or list, it's really confusing (even more confusingly, there is an std::list, but it's implemented as a linked list, and hence not usually worth using).
 
A vector is an ordered list of items of a given data type.
this is what i have as a definition but i still don't really get it.
 
i remember he said in class that we don't ACTUALLY use arrays when we code or something like that. and that got me very confused. he didn't explain it. he just mentioned something about not using them when coding and then he cut off.
 
Anthropic announced that an inflection point has been reached where the LLM tools are good enough to help or hinder cybersecurity folks. In the most recent case in September 2025, state hackers used Claude in Agentic mode to break into 30+ high-profile companies, of which 17 or so were actually breached before Anthropic shut it down. They mentioned that Clause hallucinated and told the hackers it was more successful than it was...

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
3K
Replies
6
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
20
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 13 ·
Replies
13
Views
5K