Skip to content

Instantly share code, notes, and snippets.

@aligalehban
Created June 27, 2018 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aligalehban/77f4715ee0f51e2ac1b34a99e9e51f56 to your computer and use it in GitHub Desktop.
Save aligalehban/77f4715ee0f51e2ac1b34a99e9e51f56 to your computer and use it in GitHub Desktop.
Remove all characters except alphabets in c++ source code - www.alighalehban.com
#include <iostream>
using namespace std;
int main() {
string line;
cout << "Enter a string: ";
getline(cin, line);
for(int i = 0; i < line.size(); ++i)
{
if (!((line[i] >= 'a' && line[i]<='z') || (line[i] >= 'A' && line[i]<='Z')))
{
line[i] = '\0';
}
}
cout << "Output String: " << line;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment