Re: [algogeeks] Reverse the string word by word . Can someone tell what is wrong in my code ?

2011-09-25 Thread avinesh saini
Try this one...

#include
#include
void reverse(char *p,char*q)
{
char c;
while(p wrote:

> u shud do TWO things in..your reverseword function..
> first is str[i]=='\0' and not str[i]='\0'
> second is while(i<=len) and not while(i
>
> On Sun, Sep 25, 2011 at 6:49 AM, Deoki Nandan  wrote:
>
>> //Reverse String word by word
>> // if string is :- I am a good boy
>> //output string should be :- boy good a am I
>> #include
>> #include
>> void reverse(char *p,char*q)
>> {
>> int i;char c;
>> while(p> {
>> c=*p;*p=*q;*q=c;
>> p++;
>> q--;
>> }
>> }
>>
>> void reverseWordByWord(char str[],int len)
>> {
>> int i=0,j=0;
>>
>>  while(i>  {
>>
>> if((str[i]==' ')||(str[i]=='\t')||(str[i]='\0'))
>> {
>> reverse(&str[j],&str[i-1]);
>> j=i+1;
>> }
>> i++;
>>  }
>> }
>>
>> int main()
>> {
>> char A[]="Ram is a good person";
>> int i;
>> int len=strlen(A);
>> reverse(&A[0],&A[len-1]);
>> printf("%s\n",A);
>> reverseWordByWord(A,len);
>> printf("%s\n",A);
>> return 0;
>> }
>>
>>
>> --
>> **With Regards
>> Deoki Nandan Vishwakarma
>>
>> *
>> *
>>
>>  --
>> 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.
>>
>
>
>
> --
> *Dheeraj Sharma*
> Comp Engg.
> NIT Kurukshetra
>
>
>
>  --
> 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.
>



-- 
*Avinesh Kumar,
MCA
NIT Calicut.
*

-- 
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.



Re: [algogeeks] Reverse the string word by word . Can someone tell what is wrong in my code ?

2011-09-24 Thread Dheeraj Sharma
u shud do TWO things in..your reverseword function..
first is str[i]=='\0' and not str[i]='\0'
second is while(i<=len) and not while(i wrote:

> //Reverse String word by word
> // if string is :- I am a good boy
> //output string should be :- boy good a am I
> #include
> #include
> void reverse(char *p,char*q)
> {
> int i;char c;
> while(p {
> c=*p;*p=*q;*q=c;
> p++;
> q--;
> }
> }
>
> void reverseWordByWord(char str[],int len)
> {
> int i=0,j=0;
>
>  while(i  {
>
> if((str[i]==' ')||(str[i]=='\t')||(str[i]='\0'))
> {
> reverse(&str[j],&str[i-1]);
> j=i+1;
> }
> i++;
>  }
> }
>
> int main()
> {
> char A[]="Ram is a good person";
> int i;
> int len=strlen(A);
> reverse(&A[0],&A[len-1]);
> printf("%s\n",A);
> reverseWordByWord(A,len);
> printf("%s\n",A);
> return 0;
> }
>
>
> --
> **With Regards
> Deoki Nandan Vishwakarma
>
> *
> *
>
>  --
> 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.
>



-- 
*Dheeraj Sharma*
Comp Engg.
NIT Kurukshetra

-- 
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.



[algogeeks] Reverse the string word by word . Can someone tell what is wrong in my code ?

2011-09-24 Thread Deoki Nandan
//Reverse String word by word
// if string is :- I am a good boy
//output string should be :- boy good a am I
#include
#include
void reverse(char *p,char*q)
{
int i;char c;
while(phttp://groups.google.com/group/algogeeks?hl=en.