Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- int main(void)
- {
- char buf[] = "FjsdhjhfjjhhDvdnnfbcbFbkfhdjchD";
- char s[strlen(buf)];
- char temp;
- int f_idx, d_idx;
- int d_flag = 0;
- strcpy(s, buf);
- printf("IN string: %s\n", s);
- for (int i = 0; i < strlen(s); i++)
- {
- if (s[i] == 'd' && d_flag == 0)
- {
- d_idx = i;
- d_flag = 1;
- }
- if (s[i] == 'f')
- {
- f_idx = i;
- }
- }
- printf("%n %n\n", f_idx, d_idx);
- temp = s[f_idx];
- s[f_idx] = s[d_idx];
- s[d_idx] = temp;
- printf("OUT string: %s\n", s);
- return 0;
- }
Add Comment
Please, Sign In to add comment