if (delim[b]=fileWord[b])
Firstly Assignment "=" is not equal to Equal to "==".
fileWord.erase)(i);
This would report a syntax error.
for(unsigned int a=0; fileWord.size ();a++)
Where is the condition in there?
for(unsigned int a=0;a< fileWord.size ();a++)
You should also try using iterators to go through arrays.
Another code improvment would be .
char delim[]=",.`~!@#$%^&*()_+=-{}][:';?><|";
And in the second for loop[/code]
while(delim[b]!=0)
//................
b++
Sky Diploma
Practically a Posting Shark
865 posts since Mar 2008
Reputation Points: 673
Solved Threads: 131
if (delim[b]=fileWord[b])
Firstly Assignment "=" is not equal to Equal to "==".
A little clarification: when you write if (delim[b]=fileWord[b]) thenyou're assigning the value at fileWord[b] to delim[b] , as a result the assignment operator always returns the assigned value what means that if the assigned value isn't NULL or 0 (it's the same :P) the if statement will treat the expression as false , in any other case the expression will be evaluated as true :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
is it possible to remove the punction marks with "ispunct"
No, the ispunct function is just checking whether a character is a punctuation mark or not :)
(you can find more information on 'ispunct' here )
By the way: Why don't you just use the strtok function?
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
yes so i can say that if the char is equal to ispuntc then remove the character
Yes you can, but there's an easier way:Declare a string (called 'result' for example) to store the 'stripped' string in.
Just loop through the string (containing the punctuation marks) and every time you evaluate whether the character is a punctuation mark or not, if the character is not a punctuation mark, you add it to your 'result' string, after the loop has finished you've a string which contains an 'exact' copy of the other one, but without the punctuation marks :)
To repeat what I've already said: the strtok function might be a lot easier for you, but it's your choice :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
could be be kindful to show me the sample code using strtok
There's an example provided here , just scroll the page a bit down and you'll see it :P
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Could you please post using code tags?
punct=str<strong>o</strong>tok(str," .,:'!@#"); , it isn't 'strotok', but strtok :P
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
I'm not repeating it anymore :angry:: Post using code tags !!
>how ever when i use the below code it works but not all comars get eliminated
That's just logical because you only check whether the character is a punctuation mark, and only in that case you remove the character from the string :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Post edited:: Try: strcpy(str, fileOneVector[n].c_str());
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Sorry that was my mistake, try the following:
strcpy(str, fileOneVector[n].c_str());
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243