Display input text backwards

Can someone give me string and while format program in making an input text backwards in <stdio.h> and/or <string.h>?

I dont really know how..thanks guys!
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>

using namespace std;

void reverse(char*);

int main(int argc, char *argv[]) {

	char s[80];
	
	cout << "Please input your text: ";

	cin.getline(s, 80);
	
	cout << "Your Text is : " << s << endl;

	reverse(s);

	cout << "After change: " << s << endl;

	return 0;
}

void reverse(char *s) {
	char * end;
	for (end = s; *end; end++) {}
	 	char  temp;
	    while (s < end-1) {
	    	temp = *--end;
	        *end = *s;
	        *s++ = temp;
	}
}
while this is correct, it has to be in <stdio.h> and/or <string.h>. my class hasnt covered iostream yet so it doesnt count to our proffessor :( i apologize for not explaining that early
Topic archived. No new replies allowed.