• C


how to implement strrev with out using temporary variables and recursion
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
Also, if this is an assignment it would be most helpful to post the exact wording. There are a number of ways this problem could be solved and the actual wording of the assignment will determine which is the best to consider. Once you have clarified these point either I or another expert will be more than happy to guide you through finding an appropriate solution.

nagaharikolaAuthor Commented:
this is not academic work.
I am practising string operations, i tried with recursion and using temp variables.
I am stuck up while implementing with out recursion and temp variable.

nagaharikolaAuthor Commented:
The below is the program i wrote
  char str[100],rev[100];
  char *i= str;
  char *j= rev;
  printf("enter a string\n");
printf("The string entered is %s  \nThe string after reversing is %s\n\n",str,rev);

help to implement the above program with out
  char *i= str;
  char *j= rev
Identify and Prevent Potential Cyber-threats

Become the white hat who helps safeguard our interconnected world. Transform your career future by earning your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

evilrixSenior Software Engineer (Avast)Commented:
Well, given that you are going to have to swap values around you generally need a temp variable but there is a way to avoid this.

Note, you can perform the swap in place... you don't need to swap to another string!

As for the best way of doing this, you only need to swap 1/2 the elements in the string so start at one end and swap with the counter-part at the other end. So, if a string is 5 chars long you only have to swap 0 & 4 and 1 & 3


Does that make sense?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nagaharikolaAuthor Commented:
I've requested that this question be deleted for the following reason:

got the solution
evilrixSenior Software Engineer (Avast)Commented:
So, what is the solution you used then? Please share it with us. You can then close this by accepting your own solution as the answer.
evilrixSenior Software Engineer (Avast)Commented:
FWIW; the solution I provided was quite a reasonable way to do this given your constraints. It would have been nice to have gotten some feedback from you. If it didn't solve your problem you could have said and I'd have been glad to work with you to refine it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.