this is what i have so far, i need to combine 2 c strings, print them backwards and figure out whether they are a palindrome or not.
(the for loop is where i stopped, it could be wrong)

#include<iostream> 
#include<cstring> 
using namespace std;

int main( ) 
{ 
     char s1[15], s2[8]; 
     int length1; 
     int count = 0;

     cout << "Now I let you enter two strings \n"; 
     cout << "Enter the first string, then the second \n"; 
     // Another way to initialize the two strings 
     cin >> s1 >> s2;
     strcat(s1, s2);

for(int i=0, i < length, i++)
{
        
        

      count++; 
   system("pause");
   return 0; 
}

Recommended Answers

All 6 Replies

Using strings, so concatenations will be easier ;

string firstName = "dani";
string lastName = "web";
string fullName = firstName + lastName; //concatenation
string tmp = fullName;
//reverse
std::reverse(fullName.begin(),fullName.end());
if(fullName == tmp){ cout << "Palindrome\n"; }
else cout << "Not Palindrome\n";
void main();
{
inst set=0;
char a[10];
char b[10];

for(i=0;i<10;i++)
{
for(j=10;j>0;j--)
{
if(a[i]==b[j])
{
if(a[i]==a[10])
set=1;
}
else
{
break;
}
}
if(set==1)
printf("palindrome");
else
{
printf("not");
}
}
commented: Useless, non standard, non working, unformatted code -2
int main()
{int set=0;
char a[10];
char b[10];
char *p1=a;
char *p2=&b+1 ; // for pointing memory just nxt to string
*p2--;//points "/0"
*p2--; //points end now
for(i=0;i<strlen(a[10]);i++)
{
if(*p1==*p2)
{
if(p1->next=null ||p1->next="")
 {
set=1;
 }
}
else
{
break;
}
*p1++;
*p2--;
}
if(set==1){ printf("palindrome");
}
else
{printf("not");
}


}
commented: learn to use the code tags already! -1
commented: this is utter nonsense +0

@ sourabhtripathi *p2--; does not change the memory address. it actually is subtracting 1 from the value stored at p2. also you don't have the values initialized to anything. here is a link for you. http://www.cplusplus.com/doc/tutorial/pointers/

can any one send me C++ code for 2-3-4 tree insertion, deletion and search code plz...email snipped

i want the string palindrome or not using class

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.