Here is the program to replace each string of one or more blanks by a single blank.
#include “stdio.h”
#include “conio.h”
#include “string.h”
void main()
{
char input[100],output[100],c;
int i=0,j=0;
clrscr();
printf(“Enter the string\n”);
gets(input);
for(i=0;i<strlen(input);i++)
{
if(input[i]==' '&&input[i+1]!=' ')
output[j++]=input[i];
else if(input[i]!=' ')
output[j++]=input[i];
}
output[j]='';
printf("\noutput string is\n");
puts(output);
getch();
}
Output:
Enter the string How are you ? Output string is: How are you ? |
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Resources #Terms of Use
Copyright©2012 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com