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

  • Thread starter Thread starter aliz_khanz
  • Start date Start date
AI Thread Summary
The discussion focuses on creating a function to reverse the order of characters in a text array using the `scanf` function. The initial poster expresses confusion about the assignment and requests a complete program, which is met with a reminder that assistance requires some effort on their part. Participants suggest using a swap function and loops, emphasizing the importance of a null character to determine the array length. They also question the necessity of `scanf` in this context. The conversation highlights the need for the user to engage more actively in problem-solving.
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?
 

Similar threads

Back
Top