First time post so forgive me if there is some rules I don't follow.
Now, I have an assignment in which I am to accept arguments from the command line and copy them into a cstring and display said cstring unmolested. Then I should store it into another cstring but ignore all punctuation, spaces and capital letters. Like this:
./a5 Marge lets Norah see Sharon\'s telegram
As is: Marge lets Norah see Sharon's telegram
---->: margeletsnorahseesharonstelegram
<----: margeletsnorahseesharonstelegram
Sequence entered is a palindrome
=======================================================
Finally I am to chaeck to see if it is a palindrome. Most of it works and if no spaces are entered nor punctuation it works. However, punctuation causes it to malfunction. Any help or hints would be greatly appreciated.
I'm just going to copy the function and if anyone wants the whole program I can post it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
char *FormSeqProc (int argc, char *argv[], char seqAsIs[])
{
int len = 0,
n = 0;
for (int p = 1; p < argc; ++p)
{
len += strlen(argv[p]);
}
char *seqProc = new char [len + argc + 1];
for (int p = 0; p < strlen(seqAsIs); ++p)
{
if (isalnum(seqAsIs[p]))
seqProc[n++] = tolower(seqAsIs[p]);
}
seqProc[len + argc + 1] = '\0';
return seqProc;
}
|
Thank you in advance