944,156 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 4748
  • C RSS
Nov 14th, 2007
0

vector of string

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aaabhish is offline Offline
9 posts
since Nov 2007
Nov 14th, 2007
0

Re: vector of string

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Nov 14th, 2007
0

Re: vector of string

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.
Reputation Points: 36
Solved Threads: 0
Light Poster
mohanrobin is offline Offline
34 posts
since Nov 2007
Nov 14th, 2007
0

Re: vector of string

Listen to Salem. C does not have a vector anything. Nor does it have generic anything. Those are both C++ constructs.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Nov 15th, 2007
0

Re: vector of string

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aaabhish is offline Offline
9 posts
since Nov 2007
Nov 15th, 2007
0

Re: vector of string

when we are saying vector dimention is it the memory offsets or memory segments. i have a confusion in such things.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aaabhish is offline Offline
9 posts
since Nov 2007
Nov 15th, 2007
0

Re: vector of string

So maybe in C,
  1. struct vector_of_int {
  2. int *data;
  3. size_t allocatedSize;
  4. size_t maxUsedSize;
  5. };
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
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Nov 18th, 2007
0

Re: vector of string

Click to Expand / Collapse  Quote originally posted by Salem ...
So maybe in C,
  1. struct vector_of_int {
  2. int *data;
  3. size_t allocatedSize;
  4. size_t maxUsedSize;
  5. };
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aaabhish is offline Offline
9 posts
since Nov 2007
Nov 18th, 2007
0

Re: vector of string

>>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
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: to find the square root of a number
Next Thread in C Forum Timeline: functions in c





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC