I have a fully written C++ code and i need you to solve a small problem

FratBro23
Category:
Computer Science
Price: $5 USD

Question description

I have code that is supposed to check if two strings are palindrome to each other regard less of capital or small litter or numbers and other symbols. So "racecar" is palindrome to "racecar" and also should work "racecar" is palindrome "RaC89$eca?R" but "fish" is not palindrome to "house" 

my problem is I wrote the whole code but for some reason whenever i test it, it  tells me that they are not palindromes.

this is the header:

#ifndef INTERVIEWMAYHEM_H_

#define INTERVIEWMAYHEM_H_

char normalize(char input);

bool arePalindromes (const char* s1, const char* s2);

#endif/* INTERVIEWMAYHEM_H_ */


and this is the main code:

#include<cstring>

#include"InterviewMayhem.h"

#include<iostream>

char normalize(char input)

{

return tolower(input);

}

bool arePalindromes (const char* s1, const char* s2)

{

int i;

int k=0;

char u[100];

char w[100];

char z[100];

for (int i=0; i<strlen(s1); i++) //runs through s1 string

{

z[i]=normalize(s1[i]);

if ((z[i] >'`') & (z[i]<'{'))

{

u[k]=z[i];

k++;

}

}

for (i=(strlen(s1)-1); i>=0; i--) //runs through s1 string

{

z[k]=normalize(s1[i]);

if ((z[k] >'`') & (z[k]<'{'))

{

u[k]=z[k];

k++;

}


}


for (i=0; i<(strlen(s2)); i++) //runs through s1 string

{

z[i]=normalize(s2[i]);

if ((z[i]>'`') & (z[i]<'{'))

{

w[i+1]=z[i];

}

//return w;

}

if (strcmp(w,u)==0)

{

returntrue;

}

else

{

returnfalse;

}

}

Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1823 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors