473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Vectors vs arrays

what's the difference between vectors and arrays in C?
I only knew array, as data structure, and not vector!
When must i use vector and when array?

Thanks

--

questo articolo e` stato inviato via web dal servizio gratuito
http://www.newsland.it/news segnala gli abusi ad ab***@newsland.it
Jun 27 '08 #1
5 1588
jacox said:
what's the difference between vectors and arrays in C?
Arrays exist.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #2
On 15 Apr, 09:27, jacopo...@yahoo.it (jacox) wrote:
what's the difference between vectors and arrays in C?
I only knew array, as data structure, and not vector!
When must i use vector and when array?
There are no "vectors" in C. There are in C++.
Try a C++ news group if you are interested in the
C++ answer.

--
Nick Keighley
Jun 27 '08 #3
On Tue, 15 Apr 2008 08:33:11 +0000, Richard Heathfield wrote:
>jacox said:
what's the difference between vectors and arrays in C?
Arrays exist.M
:D

--
http://lispmachine.wordpress.com/
Jun 27 '08 #4
On 15 Apr 2008 at 8:27, jacox wrote:
what's the difference between vectors and arrays in C?
I only knew array, as data structure, and not vector!
When must i use vector and when array?
In C++, a vector is an array with some additional functionality. One of
the main advantages is that vectors support bounds checking: if you use
the at() method, the access will be bounds-checked and throw an
exception if the element does not exist. (You can also avoid bounds
checking by using [], which is overloaded.)

A vector will also grow dynamically as needed when you add elements to
it: an array's size is fixed once and for all when you define it.

Jun 27 '08 #5
"jacox" <ja*******@yahoo.itwrote in message
news:fu**********@news.newsland.it...
what's the difference between vectors and arrays in C?
In C++, there is a separate type of vector defined in the C++ standard.
I only knew array, as data structure, and not vector!
"My foot was glued, like lead to the floor. That's all there is, and there
ain't no more."
-- "Hot Rod Lincoln"
When must i use vector and when array?
In C, you just use arrays.
** Posted from http://www.teranews.com **
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: FLChamp | last post by:
SOrry if this message is a little confused, it most probably reflects the state of the author! I have made a small program that plots the orbit of a planet in visual python using visual.vector...
10
by: Michael Aramini | last post by:
I need to represent 1D and 2D arrays of numeric or bool types in a C++ program. The sizes of the arrays in my intended application are dynamic in the sense that they are not known at compile time,...
12
by: Dave Theese | last post by:
Hello all, I'm in a poition of trying to justify use of the STL from a performance perspective. As a starting point, can anyone cite any benchmarks comparing vectors to plain old...
2
by: J. Campbell | last post by:
I have a class that contains an array of integers that hold the state of my 'system'. The system must be updated periodically. I need to update the whole system at once, at which point the system...
5
by: Computer Whizz | last post by:
I was reading through Accelerated C++ at work when I read through the first mention of Vectors, giving us certain functions etc. Is there any benefit of Arrays over Vectors? Since all Vectors...
3
by: Amit | last post by:
Hello. I am having some problem organizing a set of vectors. The vectors itself, could contain a pointer( say integer pointer) or could contain another object MyClass. 1>So, first of all, is...
19
by: nick | last post by:
The attached program is fine, but I need to create vectors for each AcctExample object. I know that I can do the following: vector<AcctExample> example which makes a vector of AcctExample objects...
3
by: John Bend | last post by:
Hello. Can anyone please suggest some good tutorial links where Java Vectors and Arrays are explained and compared? I'm a proficient programmer but fairly new to Java. Whilst I understand...
7
by: Mack | last post by:
Hi Guys, In C++ , i was just wondering what is the advantage of Vectors over arrays? I saw one sample program doing pretty much same way traditional vectors do then what the use of VECTORS??or...
1
by: Rob | last post by:
How would I do this? I want to be able to handle vectors of many different types of data and vectors that can contain any number of other vectors of data. Currently, I have a templated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.