Advertisement
mhrabbi

P7. Remove all characters in a string except Alphabets.

Jul 26th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     char line[150];
  5.     int i, j;
  6.     printf("Enter a string: ");
  7.     gets(line);
  8.     for(i = 0; line[i] != '\0'; ++i)
  9.     {
  10.         while (!( (line[i] >= 'a' && line[i] <= 'z') || (line[i] >= 'A' && line[i] <= 'Z') || line[i] == '\0') )
  11.         {
  12.             for(j = i; line[j] != '\0'; ++j)
  13.             {
  14.                 line[j] = line[j+1];
  15.             }
  16.             line[j] = '\0';
  17.         }
  18.     }
  19.     printf("Output String: ");
  20.     puts(line);
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement