hi all its me again, i just added a replace function but its throwing error C2661: 'std::basic_string<_Elem,_Traits,_Ax>::replace' : no overloaded function takes 2 arguments.

any idea?

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

string padBlanks(string, int);
void removeLetter(string&, char);

int main()
{
string string1;
int padN;
string inStr;
char alpha;

cout<< "Please enter a string"<<endl;
cin>> string1;
cout<< "Please enter a number"<<endl;
cin >> padN;

padBlanks(string1, padN);

cout<< "Please enter a sentence"<<endl;
cin>> inStr;
cout<< "Please enter a char to be removed"<<endl;
cin >> alpha;

removeLetter(inStr, alpha);

cin.ignore();
cin.ignore();
}

string padBlanks(string string1, int padN)
{
string blank(padN,' ');

cout<< blank <<string1<<endl;
return blank;
}

void removeLetter(string& inStr, char alpha ) 
{  
int i;
	for(  i = 0; i < inStr.length(); i++)
	{
	if (inStr[i] == alpha)
		inStr.replace(i,alpha);	
	} 
	cout<< inStr <<endl;
}

did i go wrong in the logic or misunderstood the replace function?
thanks in advance for any advice

I think you misunderstood the use of the replace function. I could give you an explanation, but the C++ reference does it better then I could :) Look closely at the examples on the bottom of the page.

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.