Created
June 27, 2018 05:22
-
-
Save aligalehban/77f4715ee0f51e2ac1b34a99e9e51f56 to your computer and use it in GitHub Desktop.
Remove all characters except alphabets in c++ source code - www.alighalehban.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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