My Program :

#include <iostream>
#include <string>
using namespace std;

void Reverse(string &InputString);


void CharSwap(char& First, char& Second);

void main(void)
{
	 string InputString;
	
	cout << "Please enter the string to reverse ==> ";
	getline(cin, InputString);
	
	cout << endl << "You entered the (" << InputString.length() 
		 << ") char long string: ";
	for(int i = 0; i < InputString.length(); i++)
		cout << InputString[i];
	
	
	Reverse(InputString);
	
	
	cout << endl << "The string reversed is : ";
	for(int j = InputString.length(); j > 0 ; j--)
			cout << InputString[j];	

	
	cout << endl << endl;
	
}


void Reverse(string &InputString)
{
	int Begin = 1,
		End = InputString.length();
	
	while(Begin < End)
	{
		CharSwap(InputString[Begin], InputString[End]);
		Begin++;
		End--;	
	}
}


void CharSwap(char& First, char& Second)
{
	char Temp;
	First = Second;
	Temp = First;
	Second = Temp;
}

<< moderator edit: added [code][/code] tags >>


Will not work It comes up with the error message "Line 11 `main' must"

How do i fix this thanks

Will not work It comes up with the error message "Line 11 `main' must"

...have return type int?

How do i fix this

Uh, give main a return type of int.

int main()
{
   // ...
   return 0;
}

What what should the code look like with int main()
{
// ...
return 0;
}

where do i place it ?

Where you have

void main(void)

Change it to

int main(void)

Then return a value before the last }.

You might have to rethink your CharSwap() function or you end up with two Seconds, a runtime error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.