Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char *DeleteEmpty (char *s)
- {
- int i=0,j=0;
- char *str2=(char*)malloc(strlen(s)+1);
- while(s!='\0');
- {
- if(s[i]!=' ')
- {
- str2[j++]=s[i++];
- }
- i++;
- }
- str2[j]='\0';
- return str2;
- free (str2);
- }
- int main()
- {
- char *str1="My dear friend";
- printf("str1為:%s\n",str1);
- printf("str2為:%s\n",DeleteEmpty(str1));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement