Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream.h>
- #include<conio.h>
- #include<string.h>
- void main ()
- {clrscr();
- cout<<"please enter a string with extra spaces : " ;
- char a[100] ;
- gets(a);
- int h = strlen(a);
- for(int i = 1 ; i <strlen(a);i++)
- { if(a[i+1] == ' ')
- if(a[i] == ' ')
- a[i] = '\n';
- }
- cout<<endl<<"the corrected statement is : ";
- for(int j = 0 ;j< h;j++)
- if(a[j] != '\n')
- cout<<a[j];
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment