Advertisement
Guest User

Prata

a guest
Apr 20th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. /* mod_str.c — модифицирует строку */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #define LIMIT 81
  6.  
  7. void ToUpper(char *);
  8. int PunctCount(const char *);
  9.  
  10. int main(void)
  11. {
  12.     system("chcp 1251");
  13.     system("cls"); 
  14.  
  15.     char line[LIMIT];
  16.     char *find;
  17.    
  18.     puts("Введите строку:");
  19.     fgets(line, LIMIT, stdin);
  20.     find = strchr(line, '\n'); // поиск символа новой строки
  21.      
  22.     if (find)                  // если адрес не является NULL,
  23.         *find = '\0';            // поместить туда нулевой символ
  24.     ToUpper(line);
  25.     puts(line);
  26.     printf("Эта строка содержит %d знаков препинания. \n", PunctCount(line));
  27.     return 0;  
  28. }
  29.  
  30. void ToUpper(char *str)
  31. {
  32.     printf("To upper result char= %c\n", toupper('d'));
  33.     while (*str)
  34.     {
  35.         *str = toupper((*str)) ;
  36.         printf("To upper result char= %c\n", toupper((*str)));
  37.        
  38.         str++;
  39.     }      
  40.        
  41. }
  42. int PunctCount(const char *str)
  43. {
  44.     int ct = 0;
  45.     while (*str)
  46.     {
  47.         if (ispunct(*str))  ct++;
  48.         str++;
  49.     }
  50.     return ct;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement