Need a project done?

C++ Programming Developer

Search This Blog

Program to Remove special characters in a String in C++.

//Program to Remove special characters in a String in C++.




#include <iostream>
using namespace std;

int main()
{
const int size = 15;
char string[size] = "1. He. is& me?";
char *sp = string;

for (int i = 0; i<size; i++)
{
if (! ispunct(string[i]) ) //true when character isn't special character.
{
*sp = string[i];
sp++;
}
}
*sp = '\0';

cout << string << endl;

return 0;
}

No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."