Remove Spaces From String C++
Here you will learn and get the program code to remove spaces from string c++ using pointers in C++ programming.
Program Code to Remove Spaces C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  | #include<iostream> #include<stdio.h> using namespace std; char *RemoveSpace(char *string1) {	 int i, k=0; for(i=0; string1[i]!='\0'; i++) { if(string1[i] != ' ') string1[k++] = string1[i]; } string1[k] = '\0'; return string1; } int main() { char string1[100];	 cout<<"\nEnter a String: "; gets(string1); cout<<"\nString after Remove Spaces : "<<RemoveSpace(string1); return 0; }  | 
Output
Enter a String: Welcome to Code Revise
String after Remove Spaces : WelcometoCodeRevise
Check out our other C++ programming Examples