#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
int i,j=0;
char str[30];
cout<<"Enter a String:n";
gets(str);
for (i=0;str[i]!='';++i) {
if(str[i]!=' ')
str[j++]=str[i];
}
str[j]='';
cout<<"nString After Removing Spaces:n"<<str;
return 0;
}
C++ Program to Remove Spaces From String
Levels of difficulty: medium / perform operation:
- C++ Program to Compare Two Strings Without Using Pointers
- C++ Program to convert first letter of each word of a string to uppercase and other to lowercase
- C++ Program to Find Substring in String (Pattern Matching)
- C++ Program to Remove Spaces From String
- C++ Program to Compare Two Strings Using Pointers
- C++ program to check the entered character is capital letter, small letter, digit or a special character