This post contains a total of 5+ C Blank Space Remover Program Examples with Source Code. All these Blank Space Remover Programs are used to remove Blank / White Space from Strings, and these programs are made using C Programming Language.
You can use the source code of these examples with credits to the original owner.
Related Posts
C Blank Space Remover Programs
1. By Nova
Made by Nova. Program To Remove Blank Spaces From An Entered String Using C. Source
Input A String : hello world Output String : helloworld
#include<stdio.h>
#include<string.h>
void main()
{
char line1[1500], line2[1500];
int i, j=0;
printf("\tRemoving Blank Spaces From An Entered String\n\n");
printf("Input A String : ");
gets(line1);
puts(line1);
for(i=0;line1[i]!='\0';i++)
{
if(line1[i]!=' ')
{
line2[j++]=line1[i];
}
}
line2[j]='\0';
printf("\nOutput String : ");
puts(line2);
}
2. By Manimaran R
Made by Manimaran R. Simple Blank Space remover program. Source
bl ank blank
#include <stdio.h>
int main() {
int i;
char str[50];
//Enter a string with spaces
scanf("%[^\n]s",str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]!=32)
printf("%c",str[i]); //Print the characters without spaces.
}
return 0;
}
3. By H. Ahmadian
Made by H. Ahmadian. A Very Simple Program To Remove Spaces From Input String. Source
Enter String: Your String: qw qw Your String After RemoveSpaces: qwqw
#include <stdio.h>
void RemoveSpaces (char*);
int main() {
char source[100];
printf("\n Enter String: ");
fgets(source, 100, stdin);
printf("\n Your String: %s",source);
RemoveSpaces(source);
printf("\n Your String After RemoveSpaces: ");
printf("%s" , source);
return 0;
}
void RemoveSpaces(char* source)
{
char* i = source;
char* j = source;
while(*j != 0)
{
*i = *j++;
if(*i != ' ')
i++;
}
*i = 0;
}
4. By Voja
Made by Voja. Program to remove empty spaces in a text and number string using malloc. Source
11 22 1122 qw er ty qwerty
#include <stdio.h>
void printWithoutSpaces();
int main() {
printWithoutSpaces();
return 0;
}
void printWithoutSpaces(){
char* p = (char*)malloc(100*sizeof(char));
char* q;
q = p;
fgets(p,100,stdin);
while(*p){
if(*p != ' ')
printf("%c",*p);
p++;
}
free(q);
}
5. By Paolo De Nictolis
Made by Paolo De Nictolis. Simple C Program to remove Blank spaces from a string with a max length limit of 100 Characters. Source
You entered: hello this is a text Without spaces: hellothisisatext
#include <stdio.h>
#define MAXLEN 100
int main() {
char str[MAXLEN];
char newstr[MAXLEN];
scanf("%[^\n]",str);
int j = 0;
for(int i = 0; i<MAXLEN; i++){
if(str[i] != ' '){
newstr[j] = str[i];
j++;
}
}
printf("You entered: %s\n", str);
printf("Without spaces: %s\n", newstr);
}
6. By Hrutik Bhalerao
Made by Hrutik Bhalerao. Source
abc def ghi abcdefghi
#include <stdio.h>
int main() {
char a[100];
gets(a);
int i=0;
while(a[i]!='\0')
{
if(a[i]!=' ')
printf ("%c",a[i]);
i++;
}
return 0;
}