Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- char * order_string(char * s)
- {
- char * head = s, * tail = s + strlen(s) - 1;
- while (head < tail)
- {
- if ( ! isdigit(*head) )
- ++head;
- else {
- char tmp = *head;
- memmove(head, head + 1, tail - head);
- *tail-- = tmp;
- }
- }
- return s;
- }
- int main()
- {
- char s_in[] = "ad2e57b6";
- printf("IN string: %s\n", s_in);
- printf("OUT string: %s\n", order_string(s_in));
- return 0;
- }
Add Comment
Please, Sign In to add comment