Computer Science, asked by Narain7192, 1 year ago

Write a program to copy input to output, replacing each string of one or more blanks by a single blank.

Answers

Answered by Anonymous
0

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();

}

Similar questions