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?

Recommended Answers

All 2 Replies

>*(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()

thanks it's work

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.