the ligic is:
you take the length of character array in a string
let's say it is 'len'
then do
int i,temp;
for(i=0;i<len/2;i++)
{
temp=arr[i];
arr[i]=arr[len-i];
arr[len-i]=temp;
}
if you think there is something wrong with it let me know.
Fernando Arturo G�mez Flores <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
>
> Please help me to get the solution of following program,
>
> Write a function reverse (str) that reverses the character string str.
Use it to write a program that reverses its input a line at a time.
>
> can any one please tell me how can i use function reverse(str) to reverse
the line at a time.Just tell me the logic,please.
>
> i am desperately waiting for the solution.
>
Sure,
#include <stdlib.h>
#include <string.h>
int main()
{
char szRev[512];
char* pReversed;
cout << "Enter the string to reverse: " << endl;
cin >> szRev;
pReversed = strrev(szRev);
cout << "The reversed string was: " << pReversed << endl;
return 0;
}
To unsubscribe : [EMAIL PROTECTED]
Do you Yahoo!?
Send holiday email and support a worthy cause. Do good.
To unsubscribe : [EMAIL PROTECTED]
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To reply to this message, go to:
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4963
Please do not reply to this message via email. (more info)
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmers-Town/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
