use ispunct to remove the punctions from the string then print the new string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
use ispunct to remove the punction in a string then print that string without punctions
#include <iostream>
#include <conio.h>
#include <cctype>
#include <string>
using namespace std;
int main()
{
cout <<"Enter a complete Sentence" <<endl;
string Sentence;
getline(cin, Sentence);
string punction;
for(string::size_type index=0; index < Sentence.size(); index++)
{
if(ispunct(Sentence[index]))
{
punction=ispunct(Sentence[index]);
}else{cout <<"failed" <<endl;}
}
cout << punction <<endl;
getch();
return 0;
}
|
my output is a right sided triangle. this is error. whats wrong?
1 2
|
if(ispunct(Sentence[index]))
punction=ispunct(Sentence[index]);
|
if
Sentence[index] is a punctuation mark then set
punction to the fact that
Sentence[index] is a punctuation mark
bazzy i dont understand,
Bazzy just paraphrased what your code actually does.
Topic archived. No new replies allowed.