C++ Program to Remove all the Blank Spaces form the String
Libraries used in this program -
1) #include<stdio.h> - It is used to perform the input and output operations using the functions print() and scanf().
2) #include<string.h> - It is a header file in C++ used to perform string operations.
C++ Program to Remove Blank Spaces -
#include<stdio.h>
#include<string.h>
int main()
{
char s[100];
int i, k=0;
printf("Enter the string:\n");
gets(s);
for(i=0;s[i];i++)
{
s[i]=s[i+k];
if(s[i]==' '|| s[i]=='\t')
{
k++;
i--;
}
}
printf("String after removing all the blank spaces:\n");
printf("%s",s);
return 0;
}
Output -
Enter the string:
Codi ng Ea z y
String after removing all the blank spaces:
CodingEazy
0 Comments