Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <ctype.h>
- #define NMAX 1000
- #define SSMAX 30
- uint32_t upper_sub_string(char *str, const char *substr) {
- uint32_t cnt = 0;
- const int lenSS = strlen(substr);
- char *p = strstr(str, substr);
- while (p != NULL) {
- for (int i = 0; i < lenSS; i++) {
- *(p + i) = toupper(*(p + i));
- }
- cnt++;
- p = strstr(p + 1, substr);
- }
- return cnt;
- }
- int main(void) {
- char s1[NMAX], s2[SSMAX];
- fgets(s1, NMAX, stdin);
- fgets(s2, SSMAX, stdin);
- s2[strlen(s2) - 1] = 0;
- printf("%d\n", upper_sub_string(s1, s2));
- puts(s1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement