Remove Spaces, Blanks From a String
In this example, you will get the program code to remove spaces from a string using pointers in c programming. Here we are using pointers and string to do the solution of this problem.
Remove Spaces from a String using pointers in C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //Remove Space From String using pointers in C #include<stdio.h> int main() { char st[80],vt[80], *p; int x=0; printf("Input any string: "); gets(st); p = st; while(*p) { if(*p != ' ') { vt[x]=*p; x++; } p++; } puts("\n***String after Removed blank spaces***\n"); puts(vt); return 0; } |
Output
Input any string: Learn Coding For Free on CodeRevise.com
***String after Removed blank spaces***
LearnCodingForFreeonCodeRevise.com
Check out our other C programming Examples