SHARE
TWEET

Untitled

a guest May 26th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. char *DeleteEmpty (char *s)
  5. {
  6.     int i=0,j=0;
  7.     char *str2=(char*)malloc(strlen(s)+1);
  8.     while(s!='\0');
  9.     {
  10.         if(s[i]!=' ')
  11.         {
  12.             str2[j++]=s[i++];
  13.         }
  14.         i++;
  15.     }
  16.     str2[j]='\0';
  17.     return str2;
  18.     free (str2);
  19. }
  20. int main()
  21. {
  22. char *str1="My dear friend";
  23. printf("str1為:%s\n",str1);
  24. printf("str2為:%s\n",DeleteEmpty(str1));
  25. return 0;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top