Start New Discussion within our Software Development Community

Hi!
I try to compile this code

while( file >> word) 

 {
	 word.size();
	 T[i]= new string[word.size()];
	 *(T[i])= word;

		i=i+1;

 }
 for (j=0;j<i;j++)
  { Bt[j] = new float [100];
	*Bt[j] = *atof(*(T[j]).c_str()); 
	
  }

but i have this problem

error C2228: left of '.c_str' must have class/struct/union

where

float **Bt ;
string  **T;

how can i fix this problem?

>*(T[j]).c_str()
Check a precedence table. Member access has higher precedence than indirection, so you're still trying to call c_str() on a pointer. The arrow operator saves you from having to remember that rule though:

T[j]->c_str()
This article has been dead for over six months. Start a new discussion instead.