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
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
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
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
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>>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
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342