C Program to remove all extra Spaces from String

In this tutorial you will learn about the C Program to remove all extra Spaces from String and its application with practical example.

C Program to remove all extra spaces from String

In this tutorial, we will learn to create a C program that will remove all extra Spaces from String using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • While loop in C Programming.

Remove all extra Spaces from String

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user as a string. Then we will remove the extra spaces for a string using a while loop.  With the help of C Programming Language.

Algorithm:-

Program:-

Remove all extra Spaces from String.

 

Output:-

In the above program, we have first initialized the required variable.

  • str[100] = it will hold the elements in an array.
  • blank[100] = it will hold the number of elements in an array.
  • c = it will hold the integer value to control the array.
  • d = it will hold the value of the blank space to be removed.

Taking input from the user in an array as a string to sort and remove extra spces.

Filtering the string value by removing the extra spaces using While Loop.

Printing output without extra blank spaces.

In this tutorial we have learn about the C Program to remove all extra Spaces from String and its application with practical example. I hope you will like this tutorial.