views:

292

answers:

4

I am suppose to create a vector array in C to use in my project. I have not worked with such data structure before, and can't seem to find good information on it.

Can you provide a link to information or post the information which describes this data structure in regard to its usage, benefits, and the functions it has.

An implementation file would be also useful reference.

A: 

Look into struct: C/C++ structures and classes.

Chad Birch
A: 

Simple google search for vector array c http://www.codecogs.com/d-ox/array/vector.php

Joshua
+3  A: 

"... can't seem to find good information on it." Wat?

Google is pretty much king.

First understand what it is. Then implement based on what you research. You're going to need to understand not only what a vector is, but pointers and structs. Ask your instructor for help, or find a peer to work on this with.

David McGraw
+1  A: 

It depends on what you mean by the terms. "Vector" has a very specific mathematical definition, but unfortunately without knowing what you goal is, "vector array" is sort of ambiguous because a vector is an array in a manner of speaking.

If you're doing mathematics in your software, you may actually want an array of vectors as opposed to an array aka vector. But, well, it depends on what you're looking to accomplish. (In my line of work, I need to deal with arrays of vector data, where the vectors are "locations" in 3D space.)

The shortest path would probably be to type:

Vector my_array[4];

...and see if that compiles. If it does not, then an array of Vector objects/structs is not available in your codebase. :)

dash-tom-bang
What's wrong with this answer?
dash-tom-bang
A Vector is a dynamic array of objects. The question is not a mathematical in nature, it's asking about implementing a vector data structure in C. Not reading the question is likely why you were bumped down.
David McGraw
So you're saying that every codebase that I've ever used, which implements a Vector as a 3D primitive (indeed, hardware even uses such a thing, as seen in MMX, SSE, etc.), implies that in fact I read the question but found it ambiguous. Getting bumped down for others' ignorance is a little sad.
dash-tom-bang
Question keys: "create a vector array in C" and "data structure". I wouldn't take it too personally. Can't control everybody.
David McGraw
A vector array is an array of vectors. Considering the ambiguity of the question, this answer is fine. I'll even upvote it for the "Vector v;" suggestion :)
aib