PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
void ShowResult(char candidates[][50], int *results); ShowResult
the piece at the end is a problem.
|
|
#define N 3
works, but you should try to avoid using the "#define" in favor of constexpr size_t MAXSIZE{ 3 };
or const size_t MAXSIZE{ 3 };
. Where "size_t" is an alias for "unsigned int". Since most things that you would use it for require a positive number it helps. Also some member functions of the STL classes have functions like "size()" and "length()" both of which return a "size_t" type. And there are other functions that return a "size_t" or "size_type" variable type.data[3];
. Using "MAXSIZE" is a better choice in case you need to change the size of the array.data[N].choise)
. First using "MAXSIZE" may have caught your attention. "data" is defined as having a size of 3. these elements are 0, 1, 2 for a total of 3. What you are using is a memory location that is outside the boundary of the array that it does not own. The results are undefined as you do not know what is at that bit of memory and if you write to that memory you have no idea what you are changing, another variable, program code or something outside the program.std::tolower()
you need the header file "<cctype>".data[N]
. This will give you a problem.system("pause");
I use this:
|
|
can you help me to change the program to opp
the program is ready but I want to change to OOP |
|
|
|
|