Accept a String and remove extra spaces from it

#include <stdio.h>
#include <conio.h>
#include<string.h>

void main()
{
char a[80];
int i=0;
clrscr();
printf("Enter the string\n");
gets(a);
while(a[i]!='\0')
{
 for(;a[i]==' ';i++);
 {
for(;a[i]!=' '&&a[i]!='\0';i++)
printf("%c",a[i]);
}
printf("%c",a[i]);}
getch();
}

No comments:

Post a Comment

Related Post

Array:
String functions:
General (Loops-for/while)
Write a Program to print reverse of a given number Write a Program to print Product of Digits (eg. 212=2*1*2=4) of a given number Write a C++ Program to Convert Binary into Decimal Number