Need quick help on my reverse function

so out += s[I-1] is the problem but how can I make it reverse?
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
#include <iostream> 
#include <string> 
using namespace std; 
void reverse(string s, int i);

int main()
{
	string strIn;
	
	cout << "Enter the a string" << endl; 
	cin >> strIn; 
	reverse(strIn, strIn.length());
	
}

void reverse(string s, int i)
{
	string out; 
	
	for (int i = 0; i < s.length(); i++)
	{	
		

		out += s[i-1]; 
	}
	cout << out << endl; 
}
Last edited on
Topic archived. No new replies allowed.