how to get rid of all spaces in a string in c

Solutions on MaxInterview for how to get rid of all spaces in a string in c by the best coders in the world

showing results for - "how to get rid of all spaces in a string in c"
Carolina
27 Nov 2017
1#include<stdio.h>
2
3char *remove_white_spaces(char *str)
4{
5    int i = 0, j = 0;
6    while (str[i])
7    {
8        if (str[i] != ‘ ‘)
9            str[j++] = str[i];
10        i++;
11    }
12    str[j] = ‘\0’;
13    return str;
14}
15
16int main()
17{
18    char str[50];
19    printf("\n\t Enter a string : ");
20    gets(str);
21    remove_white_spaces(str);
22    printf(“%s”,str);
23    return 0;
24}
queries leading to this page
program to remove all the white spaces from a string in cremove extra space in string in cremove white spaces from string in cignore spaces in string c 2b 2bhow can i remove the trailing spaces from a string in cremove space from string in cwrite c program to remove spaces 2c blanks from a string 2aremove space in c 2b 2bremove space from string cc delete empty space in stringignore space in c 2b 2b stringhow to remove spaces in the end of a string chow to remove spaces in c 2b 2bstrip from spaces in chow to remove space in a string c programmingremove spaces in string cremmove spaces from end of a string cc remove all whitespace from stringhow to remove spaces in cread string with spaces in cclean string for extra spaces cfunction to remove spaces in cc remove space from stringhow to prevent different spaces between strings cc remove space and return in stringignore space in string c 2b 2bhow to remove spaces from string in cc program to remove spaces from a stringprogram in c to remove the spaces of a string how to remove blank spaces from stringin cignore space and in string c 2b 2bremove space in a string cremove spaces from a string in chow to delete spaces from string cdelet all spaces in string in chow to remove spaces from a string in celiminate space in string chow to remove blank spaces from string using for loop in cigno space in c 2b 2b stringhow to remove space in string in chow to prevent spaces between strings cc programming remove spaces in stringdelete spaces in c c remove spaces from char arraydelete space from pointer of string in cgetting rid of spaces in chow to remove extra spaces in string cc remove spaces from stringdelete spaces from a string in cc string remove spaces from stringremove spaces from left and right in string chow to remove spaces in string in cremove all spaces from string cdelete space from string in cremoving spaces from strings cremove spacesd in a string in cremove all space in string cc remove spaces from string end and starthow to remove spaces from a string cremoves spaces from string chow to remove spaces from a sring in cremove spaces from string in cdelete space in cremove spaces from string chow to strip spaces in c functionhow to remove all spaces in a string cgetting rid of whitespace in a string in chow to remove space from string chow to get space as input in cdelete spaces in string cremove spaces from c stringremove space between string in chow to get rid of all spaces in a string in c