Here is a C++ program to remove punctuation in a string
SOURCE CODE OUTPUT
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str[100],punc[16]={'.',',',';',':','?','!','\'','-','_','"','(',')','[',']','{','}'};
cout<<"Enter string : ";
cin.getline(str,100);
for(int i=0;str[i]!='\0';i++)
{
for(int y=0;y<=15;y++)
if(str[i]==punc[y])
str[i]=' ';
}
cout<<str;
return 0;
}
#include<string.h>
using namespace std;
int main()
{
char str[100],punc[16]={'.',',',';',':','?','!','\'','-','_','"','(',')','[',']','{','}'};
cout<<"Enter string : ";
cin.getline(str,100);
for(int i=0;str[i]!='\0';i++)
{
for(int y=0;y<=15;y++)
if(str[i]==punc[y])
str[i]=' ';
}
cout<<str;
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment