SHARE
TWEET

Untitled

a guest Jan 17th, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdio.h"
  2. #include "stdlib.h"
  3. #include "string.h"
  4.  
  5. char* string();
  6.  
  7. int main() {
  8.  
  9.     printf("%s", string());
  10.  
  11.     return 0;
  12. }
  13.  
  14. char* string() {
  15.     char input[128];
  16.     printf("enter a word: ");
  17.     scanf(input, "%s");
  18.     int counter = 0;
  19.     char temp[128];
  20.     int i = 0;
  21.     while (i < input[i]) {
  22.         if ('a' <= input[i] && input[i] <= 'z') {
  23.             temp[counter] = input[i];
  24.             counter++;
  25.         }
  26.         else if ('A' <= input[i] && input[i] <= 'Z') {
  27.             temp[counter] = input[i]+32;
  28.             counter++;
  29.         }
  30.         else if (input[i] == '.' || input[i] == ',' || input[i] == '?' || input[i] == '!') {
  31.             temp[counter] = input[i];
  32.             counter++;
  33.         }
  34.         i++;
  35.     }
  36.     char* output = (char*)malloc(counter * sizeof(char));
  37.     i = 0;
  38.     while (i < counter) {
  39.         *(output + i) = temp[i];
  40.         i++;
  41.     }
  42.     *(output + counter) = '\0';
  43.  
  44.  
  45.     return output;
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top