I want to reverse each word of every string this program works fine for small number of inputs. But when I try to input many lines the programs its occurs runtime error for Example: if "I input hate you." output will be "I tupni etah .uoy"
#include<stdio.h>
int main(){
// freopen("output.txt","w",stdout);
char string[256];
int i,j,word_start;
while(gets(string)){
for(word_start=0,i=0;1;i++){
if(string[i]==' '|| string[i]=='\0'){
for(j=i-1;j>=word_start;j--)
putchar(string[j]);
putchar(' ');
word_start=i+1;
if(string[i]=='\0')
break;
}
}
putchar('\n');
}
return 0;
}
Compiler C++11ISO
Sample Inputs:
Assure polite his really and others figure though. Day age advantages end sufficient eat expression travelling. Of on am father by agreed supply rather either. Own handsome delicate its property mistress her end appetite. Mean are sons too sold nor said. Son share three men power boy you. Now merits wonder effect garret own.
Attention he extremity unwilling on otherwise. Conviction up partiality as delightful is discovered. Yet jennings resolved disposed exertion you off. Left did fond drew fat head poor. So if he into shot half many long. China fully him every fat was world grave.
This is the problem!!!
My email is a@aa@aaa.com@
every dot is a . but not all dots are .s
is it a good test case ?
aa.bb.aa.
a.....aaaa..a..a.a..a
''.'sd.f'df'.df.'f.'
...adf....fds....sdf
.,,;;,',[,;,
sdfklj ,s,df, /////sdfdf
123456 aasdf
568 sdf a1b2c3 :)
i am r2d2.
adfsaf 4-34549230 3
adffsflkdajflkdsajflafda afdsf 9024334242342342
,.z,.czxvkjwoijeoinlkf 2890ilakjnnc
dsakff;kdsafdafsaf adfaf
Sample Output should be
erussA etilop sih yllaer dna srehto erugif .hguoht yaD ega segatnavda dne tneiciffus tae noisserpxe .gnillevart fO no ma rehtaf yb deerga ylppus rehtar .rehtie nwO emosdnah etaciled sti ytreporp ssertsim reh dne .etiteppa naeM era snos oot dlos ron .dias noS erahs eerht nem rewop yob .uoy woN stirem rednow tceffe terrag .nwo
noitnettA eh ytimertxe gnilliwnu no .esiwrehto noitcivnoC pu ytilaitrap sa lufthgiled si .derevocsid teY sgninnej devloser desopsid noitrexe uoy .ffo tfeL did dnof werd taf daeh .roop oS fi eh otni tohs flah ynam .gnol anihC ylluf mih yreve taf saw dlrow .evarg
sihT si eht !!!melborp
yM liame si @moc.aaa@aa@a
yreve tod si a . tub ton lla stod era s.
si ti a doog tset esac ?
.aa.bb.aa
a..a.a..a..aaaa.....a
'.f'.fd.'fd'f.ds'.''
fds....sdf....fda...
,;,[,',;;,,.
jlkfds ,fd,s, fdfds/////
654321 fdsaa
865 fds 3c2b1a ):
i ma .2d2r
fasfda 03294543-4 3
adfalfjasdklfjadklfsffda fsdfa 2432432424334209
fklnioejiowjkvxzc.,z., cnnjkali0982
fasfadfasdk;ffkasd fafda