For lines 23 and 22 it says "you cannot assign to a variable that is constant."
anyone know how to fix this?
thanks in advanced, bookmark.

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


void print (const string & s);
string reverse(const string & s);

int main(){

print("blah");
reverse("blah");


 system("pause");
}												
void print (string & s){
	  int i;   
	  int clrscr();  
		for(i=0;i<4;i++)  
 {          
	 cout <<  s[i] << endl;       
		}			}							  // function 1 end;


string reverse(const string & s)	  {
		reverse(s.begin(), s.end());
			 cout << s << endl;
			 return 0;
}								  // function 2 end;

On line 34 it says that std::string : illegal use of this as an expression
anyone know how to fix this?

#include <iostream>
#include <string>

using namespace std;		   

void print (const string & s);
void ReverseString( const string & s);
void tnirp(const string & s);
unsigned count( const string & s, char c );

int main(){

print("blah");
ReverseString("blah");
tnirp("blah");
count("sassafrass",'s');


 system("pause");
}												
void print (const string & s){
	  int i;   
	  int clrscr();  
		for(i=0;i<5;i++)  
 {          
	 cout <<  s[i] << endl;       
		}			}			  // function 1 end;



void ReverseString(const string & s)
	{
		char t[256];
	int x = string.length(s)-1;
	for(int y = x; y >= 0; y--)
	{
	 t[x-y] = s[y];
	}
	cout << s;
	}
  // function 2 end;

void tnirp(const string & s){

		  int i;   
	  int clrscr();  
		for(i=0;i<5;i++)  
 {          
	 cout <<  s[i] << endl;       
		}}					  // function 3 end;

In the second one, length is a method of the string class, so therefore you call it on s directly, like s.length()

In the first one, in the forward declaration of print s is declares as a const string... (might be the problem)

hi

for the second problem replace it with this

int x ;
	x= s.length();
	x--;
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.