If its allowed in Haskell then only one line is enough.

import Data.List
stringWithspace :: String -> String
stringWithspace xs = unwords.words $ xs
You can run this program on ideone [ http://ideone.com/RloOE ]

On Aug 12, 8:00 pm, ankit sambyal <ankitsamb...@gmail.com> wrote:
> Guys sorry for posting the buggy code .  Here is the working code :
>
> void delExtraSpaces (char Str[])
> {
> int Pntr = 0;
> int Dest = 0;
>  int flag=0;
> while (Str[Pntr]!='\0')
> {
> if (Str[Pntr] != ' ')
> {
>       Str[Dest++] = Str[Pntr];
>       flag=0;}
>
> else if(Str[Pntr]==' '  && flag==0)
> {
>       Str[Dest++] = Str[Pntr];
>       flag=1;
>
> }
>
> Pntr++;
>
> }
>
> Str[Dest] = '\0';
>
>
>
>
>
>
>
> }

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to