New Android apps UniqueKey

Sunday, 22 February 2015

Removing white space from a string.


#include<stdio.h>

main()
{
    char str[150];
    int i,j;
    
    printf("Enter a string: ");
    gets(str);
    
    for(i=0; str[i]!='\0'; i++)
    {
        while (!((str[i]>='a'&&str[i]<='z') || (str[i]>='A'&&str[i]<='Z' || str[i]=='\0')))
        {
            for(j=i;str[j]!='\0';++j)
            {
                str[j]=str[j+1];
            }
            str[j]='\0';
        }
    }
    printf("Output String: ");
    puts(str);
}

No comments:

Post a Comment