Question: Need help getting this c++ code to work in Visual Studios 2017 // ConsoleApplication1.cpp : Defines the entry point for the console application. // #include

Need help getting this c++ code to work in Visual Studios 2017

// ConsoleApplication1.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include

#include

#include

using namespace std;

using std::string;

// A utility function to print a substring str[low..high]

void printSubStr(char* str, int low, int high)

{

for (int i = low; i

printf("%c", str[i]);

}

// This function prints the longest palindrome substring

// of str[].

// It also returns the length of the longest palindrome

void findpalidrone(char *str)

{

int n = strlen(str); // get length of input string

// table[i][j] will be false if substring str[i..j]

// is not palindrome.

// Else table[i][j] will be true

bool table[n][n];

memset(table, 0, sizeof(table));

// All substrings of length 1 are palindromes

int maxLength = 1;

for (int i = 0; i

table[i][i] = true;

// check for sub-string of length 2.

int start = 0;

for (int i = 0; i

{

if (str[i] == str[i + 1])

{

table[i][i + 1] = true;

start = i;

maxLength = 2;

}

}

// Check for lengths greater than 2. k is length

// of substring

for (int k = 3; k

{

// Fix the starting index

for (int i = 0; i

{

// Get the ending index of substring from

// starting index i and length k

int j = i + k - 1;

// checking for sub-string from ith index to

// jth index iff str[i+1] to str[j-1] is a

// palindrome

if (table[i + 1][j - 1] && str[i] == str[j])

{

table[i][j] = true;

if (k > maxLength)

{

start = i;

maxLength = k;

}

}

}

}

if (maxLength == 1 || maxLength == 2) {

cout

cout

}

else if (n == maxLength) {

cout

}

else {

cout

cout

cout

printSubStr(str, start, start + maxLength - 1);

printf(" The order is: %d ", maxLength);

}

}

int main()

{

bool flag = true;

while (flag) {

char str[] = "";

cout

cin >> str;

if (strcmp(str, "***") == 0) {

flag = false;

}

else {

findpalidrone(str);

cout

}

}

return 0;

}

Getting the following errors

Need help getting this c++ code to work in Visual Studios 2017

Need my output to look like this

// ConsoleApplication1.cpp : Defines the entry point for the console application. //

Error List 6 Errors AoWarnings o Messages Build-Intelisense Entire Solution Scarch Error List Code Description Project File Line Suppression State t E0028 expression must have a constant value C2131 expression did not evaluate to a constant ? C3863 array type 'bool [n][n" is not assignable C3863 array type 'bool [nl[nJ' is not assignable C3863 array type 'bool [n][nl' is not assignable ConsoleApplication1 ConsoleApplication1 ConsoleApplication cnsoleapplicationl.cpp 35 ConsoleApplication consoleapplication1.cpp 43 ConsoleApplication1 consoleapplicationl.cpp 65 consoleapplication1.cpp 29 Error List 6 Errors AoWarnings o Messages Build-Intelisense Entire Solution Scarch Error List Code Description Project File Line Suppression State t E0028 expression must have a constant value C2131 expression did not evaluate to a constant ? C3863 array type 'bool [n][n" is not assignable C3863 array type 'bool [nl[nJ' is not assignable C3863 array type 'bool [n][nl' is not assignable ConsoleApplication1 ConsoleApplication1 ConsoleApplication cnsoleapplicationl.cpp 35 ConsoleApplication consoleapplication1.cpp 43 ConsoleApplication1 consoleapplicationl.cpp 65 consoleapplication1.cpp 29

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!