This is a program to remove all special characters from a string and store the alphabets in a but it doesn't store anything beyond the first space. when the input is "Life is beautiful", the output is "Life".
#include <iostream>
#include <string.h>
using namespace std;
int main(){
string mes="";
string pas;
string tem;
cin>>tem;
cin>>pas;
for (int i=0;i<tem.length();i++){
char c=tem[i];
int ch=(int)c;
if(( ch >= 65 && ch <= 90) || ( ch >= 97 && ch <= 122))
mes+=c;
else
continue;
}
cout<<mes;