How to Reverse Characters in a Text Array Using the Scanf Function

  • Thread starter Thread starter aliz_khanz
  • Start date Start date
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
aliz_khanz
Messages
26
Reaction score
0

Homework Statement



Write a function reverse which inverts the order of character in the text array.
void reverse(char s[])
// s[] – the array containing the character which order has to be inverted
Apply this funtion in a program which inverts the characters in all input lines.

Homework Equations



Scanf maybe ...%"anything"

The Attempt at a Solution



I don't really know where to start as I am unable to understand the question. Can anyone please write this programme for me? I just know that scanf function will be used in order to write the programme.
 
Physics news on Phys.org
aliz_khanz said:

Homework Statement



Write a function reverse which inverts the order of character in the text array.
void reverse(char s[])
// s[] – the array containing the character which order has to be inverted
Apply this funtion in a program which inverts the characters in all input lines.

Homework Equations



Scanf maybe ...%"anything"

The Attempt at a Solution



I don't really know where to start as I am unable to understand the question. Can anyone please write this programme for me? I just know that scanf function will be used in order to write the programme.
No, we aren't going to write this program for you. That's not what we do here. We're happy to help you, but you need to make some effort at solving this problem before we can help.

If the user enters the string, "Hi, how are you?" the program should reverse the characters to produce this string "?uoy era woh ,iH"
 
Hints,

The last character in the array should be a null, use that to get the length. Try looking up a swap function. Are you familiar with loops? Also I don't see a use for scanf?