Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX_SIZE 100
- char* cleanText(char* text) {
- int size = 0;
- int newSize = 0;
- char c;
- char* output;
- for(int i = 0; i < MAX_SIZE; i++) {
- c = *(text + i);
- if(c == '\0') {
- break;
- }
- if((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) {
- size++;
- }
- }
- output = (char*) malloc(sizeof(char) * (size + 1));
- for(int i = 0; i < MAX_SIZE; i++) {
- c = *(text + i);
- if(c == '\0') {
- break;
- }
- if((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) {
- *(output + newSize++) = c;
- }
- }
- *(output + size) = '\0';
- return output;
- }
- int main() {
- char input[MAX_SIZE];
- char* clean;
- scanf("%s", input);
- clean = cleanText(input);
- printf("%s", clean);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement