Converting std::string to char array []
Following code removed punctuation marks correctly from char array. Now
rather taking static line, I use std::string line then how it would look
like?
#include <cctype>
#include <iostream>
int main()
{
char line[] = "ts='TOK_STORE_ID'; one,one, two;four$three two";
for (char* c = line; *c; c++)
{
if (std::ispunct(*c))
{
*c = ' ';
}
}
std::cout << line << std::endl;
}
No comments:
Post a Comment