[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1894
  • Last Modified:

Bloodshed Dev C++ dynamic array or similar data structure

Hello Experts,

I am working on my first C++ project using the Bloodshed Dev C++ compiler.  I have a class called DecisionMaker with a modification member function void addDecision ( string thisChoice) whose task is to add the string variable thisChoice to an array string decisions[].

Here is the code for the void addDecision ( string thisChoice) function I have so far, which works until I after I enter a third option. Then it crashes, I think because I'm not defining how big the array is.

	void decisionMaker::addDecision ( string thisChoice )
		int arraySize;
		decisions[count] = thisChoice;
		count += 1; // increment the count of entries

Open in new window

What I would like to be able to do is create the array with size 1. Then as the user makes entries, the size of the array is increased with each entry.

Maybe, an array is the best approach for this task. Would  vector or list be better?


Anthony Berenguel
Anthony Berenguel
1 Solution
Hamidreza VakilianSenior iOS DeveloperCommented:
As its your first project I suggest you to create a linked list; therefore adding and removing entries will be much easy using malloc and free commands.

Tutorials for inplementing linked lists in c++:
Anthony BerenguelAuthor Commented:
Thank you for that direction, Programmer-X. I will try that this evening after work.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now