Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char* newString (char* str)
- {
- int j = 0;
- int i;
- int len = strlen(str);
- char *res = malloc(100);
- for (i = 0; i < len; i ++) {
- if (str[i] == ' ') {
- if (j == 0)
- continue;
- if (i + 1 < len && str[i + 1] == ' ')
- continue;
- }
- res[j] = str[i];
- j++;
- }
- return res;
- }
- int main()
- {
- char *start = malloc(100);
- gets(start);
- printf("%s", newString(start));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement