954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

vector of string

hi,

i have a doubt in vector strings what are these vector strings.
and if this is a vector how to find the dimention of these vector or what
is the dimention of this vector.

and how to do vector string things in c language.

aaabhish
Newbie Poster
9 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

C doesn't have anything like say std::vector<std::string> of C++.

So the question becomes how much of it are you going to simulate in C, say using some 'class-like' functions and dynamic memory allocation.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

i think vector strings are generic functions that you have to study generic files which is in c language.the vector strings can see in some textb books.

mohanrobin
Light Poster
34 posts since Nov 2007
Reputation Points: 36
Solved Threads: 0
 

Listen to Salem. C does not have a vector anything. Nor does it have generic anything. Those are both C++ constructs.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

ok, but i think it can be done using memory allocation funtion like melloc and calloc.
but have a confusion what i called as vector dimention.

aaabhish
Newbie Poster
9 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

when we are saying vector dimention is it the memory offsets or memory segments. i have a confusion in such things.

aaabhish
Newbie Poster
9 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

So maybe in C,

struct vector_of_int {
  int   *data;
  size_t allocatedSize;
  size_t maxUsedSize;
};

Now create a bunch of access functions which take a vector_of_int as one of the parameters, and make it do things like
- allocate space
- extend space
- free space
- save an int
- return an int

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

So maybe in C,

struct vector_of_int {
  int   *data;
  size_t allocatedSize;
  size_t maxUsedSize;
};

Now create a bunch of access functions which take a vector_of_int as one of the parameters, and make it do things like - allocate space - extend space - free space - save an int - return an int


here in this code what is size_t . is it something predefined datatype.

aaabhish
Newbie Poster
9 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

>>what is size_t . is it something predefined datatype.
Yes -- most compiler define it as either long or unsigned long. But compilers are free to define it however it wants, uncluding long long

Ancient Dragon
Retired & Loving It
Team Colleague
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You