string question

I want to insert a series of characters into a string... These characters are stored in a multidimensional array and are not necessarily known. I am trying to do this using the string.insert() function however i am getting an error

Error 1 error C2664: 'std::_String_iterator<_Elem,_Traits,_Alloc> std::basic_string<_Elem,_Traits,_Ax>::insert(std::_String_const_iterator<_Elem,_Traits,_Alloc>)' : cannot convert parameter 1 from 'char' to 'std::_String_const_iterator<_Elem,_Traits,_Alloc>' c:\users\tyler\documents\visual studio 2010\projects\cs150_program_3\cs150_program_3\grid_driver.cpp 121 1 cs150_Program_3

I don't understand what a string is if not a series of characters so i cant figure out why it is upset that i am trying to insert characters into it help?
How about posting the line that causes the problem?
You can insert character sequences into a string just fine.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
string temp;
	int i, j;
	//gets horizontal number groups
	for(i=0;i<G.getHeight();i++)
	{
		for(j=0;j<G.getWidth();j++)
		{
			if (G.at(i,j)!= 'X')
			{
				temp.insert(j, G.at(i,j));
			}
			if (G.at(i,j)== 'X')
				break;
		}//inner for
		if ((int) temp.size() >= Sizes[0] && (int) temp.size() <= Sizes[K])
			list.insert(temp);
		temp.clear();
	}//outter for 


this is it basically... G.at(i,j) is calling a class member function that is returning the address of the character in a specific position of an array
i think i have solved my problem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
string temp;
	int i, j;
	//gets horizontal number groups
	for(i=0;i<G.getHeight();i++)
	{
		for(j=0;j<G.getWidth();j++)
		{
			if (G.at(i,j)!= 'X')
			{
				temp+=G.at(i,j);
			}
			if (G.at(i,j)== 'X')
				break;
		}//inner for
		if ((int) temp.size() >= Sizes[0] && (int) temp.size() <= Sizes[K])
			list.insert(temp);
		temp.clear();
	}//outter for 

i didn't know about the append function
granted there are all sorts of other things wrong with this lol
Topic archived. No new replies allowed.