Advertisement
zsoltizbekk

torol

Apr 14th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. char *trim( char *a )
  7. {
  8.     int i, j, szamlalo=0, x=0;
  9.     char *masolat;
  10.     char *hol;
  11.     char b[]=" ";
  12.  
  13.     masolat = (char *) malloc(30);
  14.     strcpy(masolat, a);
  15.  
  16.     while ((hol=strstr(masolat, b))!=0){
  17.         if (strcpy(hol,hol+strlen(b)))
  18.             szamlalo++;
  19.     }
  20.     return masolat;
  21. }
  22.  
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. int main()
  27. {
  28.   char s[ 1000 ];
  29.   char *trim( char * );
  30.   while ( gets( s ) != NULL )
  31.   {
  32.     char *p = trim( s );
  33.     puts( p );
  34.     free( p );
  35.   }
  36.   return EXIT_SUCCESS;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement