Write a program that accepts c string input

closed account (9L8T0pDG)
I need help with this programming problem. I have no clue what to do, please help me. Where do I start what needs to be written? I am not a programmer and I cannot do this without help.


Write a program that accepts a cstring input from the user and reverses the contents of the string. The program should work by using two pointers. The head pointer should be set to the address of the first character in the string, and the tail pointer should be set to the address of the last character in the string. (the character before the terminating NULL). The program should swap the characters referenced by these pointers, increment head to point to the next character, decrement tail to point to the second to last character and so on until all characters have been swapped and the entire string reversed.
Have you gotten input from the user into a char s[100]; before?
Have you looped through the string using char*s before?

Your task involves doing this, except that you will use two pointers into the string: one starting at the front and one starting at the back. The loop will increment the first and decrement the second until they meed in the middle.

It might help you a lot to get out a piece of paper and pencil and draw what you would like to happen.

Hope this helps.
Topic archived. No new replies allowed.