C Remove punctuation from string

I have a string and I want to remove all punctuation marks from it. How can I do it? I did some research and found that people use the ispunct() function (I tried), but I can’t seem to get it to work in my code. Does anyone have any ideas?

#include 

int main() {

string text = "this. is my string. it's here."

if (ispunct(text))
text.erase();

return 0;
}
Use algorithm remove_copy_if: –

string text,result;
std::remove_copy_if(text.begin(), text.end(),
std::back_inserter(result), //Store output < br /> std::ptr_fun(&std::ispunct)
);

I have a string and I want to delete it All punctuation. How do I do it? I did some research and found that people use the ispunct() function (I tried), but I can't seem to get it to work in my code. Does anyone have any ideas?

#include 

int main() {

string text = "this. is my string. it's here."

if (ispunct(text))
text.erase();

return 0;
}

Use algorithm remove_copy_if: –

string text,result; 
std::remove_copy_if(text.begin(), text.end(),
std::back_inserter(result), //Store output
std::ptr_fun (&std::ispunct)
);

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2183 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.