Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- void zamjeni(char* string, char stari, char novi)
- {
- char temp[100];
- char* p = string;
- char* q = temp;
- int counter;
- while(*p != '\0')
- {
- if(*p == stari)
- {
- counter = 0;
- while(*p == stari && *p != '\0')
- {
- counter++;
- p++;
- }
- if(counter >= 2)
- *q++=novi;
- }
- *q++=*p++;
- }
- *q = '\0';
- strcpy(string, temp);
- }
- int main()
- {
- char string[] = "XYZZDZZZAW";
- zamjeni(string, 'Z', '*');
- puts(string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment