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 izmjeni(char* string, char znak, int n)
- {
- char temp[100];
- char* p = string;
- char* q = temp;
- int i;
- while(*p != '\0')
- {
- if(*p == znak)
- {
- for(i=0; string[i] != '\0' && i<n-1; i++, q++)
- *q = znak;
- }
- *q++=*p++;
- }
- *q = '\0';
- strcpy(string, temp);
- }
- int main()
- {
- char string[] = "abc tbc";
- izmjeni(string, 'b', 3);
- puts(string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment