Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char *str_func(char *str, char ch, int num)
- {
- int i, j = 0, size=0,count=0,temp=num;
- char* new_str = (char *)malloc(sizeof(str) * sizeof(char));
- for (i = 0; str != '\0'; i++)
- {
- if (num >= 0)
- {
- if (str[i] != ch)
- {
- new_str[j++] = str[i];
- new_str = (char*)(new_str, ++size * sizeof(char));
- }
- }
- count++;
- }
- if (temp <= count)
- {
- str[size - 1] = '\0';
- strcat(new_str, (str + temp));
- }
- else
- return NULL;
- return new_str;
- }
- void main()
- {
- char str[] = "heoolloo my noame is bob";
- char *str1;
- str1 = str_func(str, 'o', 30);
- printf("%s\n", str1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement