Simple for others , not for me.
How do you allocate memory for an array of pointers, each pointer pointing on a string.
The problem is , that the size of the array could change depending on the number of strings the user wants to enter.
This needs to be done in a function.
There are other functions needed to be written from the main.
At least get me started
zprise
0
Newbie Poster
Recommended Answers
Jump to PostIn c++ you have the choice of using either
new
operator ormalloc()
function to allocate that memory.new
is preferred in c++ butmalloc()
may be a better solution when you need to change the size of the array while the program is running.An …
Jump to PostJust use a vector of strings.
Oh and it is not a good idea to mix malloc in c++, always stick to using new and delete if you must... here's why.
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=33
All 8 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
zprise
0
Newbie Poster
iamthwee
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
iamthwee
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
zprise
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.