C++ :: Ignoring Punctuation When Copying Cstrings
Jul 29, 2014
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.
char *FormSeqProc (int argc, char *argv[], char seqAsIs[]) {
int len = 0,
n = 0;
for (int p = 1; p < argc; ++p) {
len += strlen(argv[p]);
[Code] ....
View 6 Replies
Mar 7, 2013
My program is a dictionary vector with a cin at the end that will read your input and check if it's in the dictionary.
#include "std_lib_facilities_3.h"
#include <algorithm>
#include <string>
#include <iostream>
string translate_to_lower(string s){
transform(s.begi[/code]n(), s[/code].end(), s.begin(), (int (*)(int)) tolower);
[Code] ...
How do I make the program accept inputs such as "hello?", "hello!", and "hello,"?
View 1 Replies
View Related
Mar 20, 2013
Here's my code:
struct Member {
char *name;
char *address;
char Interests[][10];//<------problem
int numofInterests;
Numbers digits;
[Code] ....
Now the Program:
newMember.Interests[numofInterests];
newMember.numofInterests = numofInterests;
for(int i = 0; i < numofInterests; i++) {
printf("Enter %s's %i interest: ", newMember.name, (i+1));
[Code] ....
it's a array of cstrings, but i can't figure out how keep it from outputting garbage, i'm assuming it's because i didn't end it with a null terminator but when i did, it didn't work.
View 1 Replies
View Related
Dec 11, 2014
I have it searching through the entire string letter by letter, looking for spaces, punctuation, etc... yet it still is continuing on with the space.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <stdio.h>
#include <cctype>
#include <algorithm>
[Code] ....
Output:
if(str_word == " ")
//or
if(str_word == ' ')
It does nothing to change it. I am completely baffled.
View 4 Replies
View Related
Feb 28, 2014
I had an assignment to do a palindrome program but im stuck in this part.
"This c-string will be sent to a function that will remove all spaces and punctuation marks from its c-string as well as change any uppercase letters to lowercase. Use string tokens to eliminate the spaces & punctuation marks. Make sure you include the NULL as you concatenate the tokens into a c-string. Then copy back into the original c-string for the pass by reference."
void tokenptr(char drome[]) {
char *token;
size_t i;
token = strtok(drome, " ,.!:;?");
while (token != '