Pages

Write a program in C language that replace spaces by another character or remove spaces

Sunday, 23 March 2014

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    char arr[500];
    int ch, count = 0;
    while(ch != 13)
    {
           ch = arr[count] = getche();
           if(ch == 32)
           {
               arr[count] = '-'; //space is replaced by -
           }
           count++;
    }
    cout << endl;
    for(int i = 0; i<= count-1; i++)
    {
         cout << arr[i];
    }
    cout << endl;
    system("pause");
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *