now...like...i need to concatenate the two words that the user enters, s1 and s2 and output them...i thought i needed to use strcat but like...i dont really understand how to do that here, do i need to make a new c string variable or...? ah i hate this stuff lol but i need to use c strings
i also somehow need to test to see if the word is a palindrome. same backwards and forwards, like mom, wow, racecar
can i get pointed in the right direction here? i dont understand c++ that well even with extra tutoring every week (networking major :p)
so can i get some help please?
#include "stdafx.h"
#include<iostream>
#include<cstring>
using namespace std;
int main( )
{
char s1[100], s2[100;
int length1, length2;
int count = 0;
// Initialize the two strings
strcpy(s1,"Black");
strcpy(s2,"Black");
while(count < 2)
{
if(count > 0)
// After the first time ask the user to enter them
{
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;
}
// Find their lengths
length1 = strlen(s1);
length2 = strlen(s2);
// Compare their length
if(length1 == length2)
{
cout << "The two strings are the same length, are they the same? \n";
}
// See if they are the same
if(! strcmp(s1, s2) )
{
cout << "The two strings: ";
cout << s1 << " and " << s2 << " are the same \n";
}
else
{
cout << "The two strings: ";
cout << s1 << " and " << s2 << " are NOT the same \n";
}
count++;
}
system ("PAUSE");
return 0;
}