Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,921 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,773 people online right now. Registration is fast and FREE... Join Now!




vectors v/s arrays

 
Reply to this topicStart new topic

vectors v/s arrays

prads
16 Mar, 2008 - 11:27 PM
Post #1

D.I.C Head
**

Joined: 22 Oct, 2007
Posts: 111


My Contributions
hello,
does using vectors instead of arrays reduce the execution time when running through huge loops?
For eg say i have an array A[38000] whose value changes within a loop that again runs 30000 times.......

CODE

int A[38000];
for(int i=0;i<30000;i++)
A[i]=X[i]*Y[i];
B[i]=A[i]*X[i];
//more statements which changes A[i];
//the above statements are just an example and not what i actually have;


Which one is advisable?
Thanks,
prads
User is offlineProfile CardPM
+Quote Post

nirvanarupali
RE: Vectors V/s Arrays
17 Mar, 2008 - 12:01 AM
Post #2

D.I.C Foot
Group Icon

Joined: 1 Aug, 2007
Posts: 983



Thanked: 2 times
Dream Kudos: 375
My Contributions
Few things about standard vector.


1. Reading into a standard vector guarantees that you don't overflow some arbitrary buffer.
2. A vector knows its size, so you don't have to count elements. ( The size increases everytime you
add elements.)

For more info: read the C++ Programming Language 3rd Ed

Arrays are fixed. You cannot change its size at run-time.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 10:12PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month