Advertisement
salmancreation

Remove Speace from Input String in C

Oct 7th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int i,j=0;
  6.     char str[100];
  7.     printf("Please Enter a String :\n");
  8.     gets(str);
  9.  
  10.     for(i=0;str[i]!='\0';++i)]
  11.     {
  12.         if(str[i]!=' ')
  13.             str[j++]=str[i];
  14.     }
  15.  
  16.     str[j]='\0';
  17.  
  18.     printf("\nString After Removing Spaces:\n\n%s\n",str);
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement