Hi
I have written a function that will search through a document and extract some data. The function takes one letter at a time and then stores it in a char array 'array1'.Now I need to convert it into a string array but I am having great trouble getting the code right.
I am trying to use the 'assign' function but it does not seem to be working.
I hope that you can help me!
Thanks!
I have written a function that will search through a document and extract some data. The function takes one letter at a time and then stores it in a char array 'array1'.Now I need to convert it into a string array but I am having great trouble getting the code right.
I am trying to use the 'assign' function but it does not seem to be working.
I hope that you can help me!
Code:
void SearchforVars(string Line,int initial, int &start_position, int &end_position, int one, int two)
{
char array1[100];
string varname;
for (int i= initial;i < Line.length(); i++)
{
if ((Line[i] != one) && (Line[i] != two))
{
start_position = i;
break;
}
}
int x = 0;
for (int n=start_position;n < Line.length(); n++)
{
if (Line[n] == one)
{
end_position = n;
break;
}
dataout << Line[n];
array1[x] = Line[n];
//cout << array1[x];
}
varname.assign(array1);
cout << varname;
}
Comment