can somebody explain me what's the cause of error
the line which stops the program is tagged below
bool checkString( string s)
{
int m = 0;
for ( ; m <=( s.length()-1); m++ )
if ( s[m+1] < s[m] )
break;
if ( m == (s.length()-1) )
return true;
else return false;
}
int main()
{
int t;
cin >> t;
string s;
while (t--)
{
cin >> s;
int k = 0;
int lenght = s.length();
char* suit[static_cast<int>(pow(2,(s.length()-2)))];
for ( int i = 1; i < s.length(); i++ )
for ( int j = 1; j != 0; )
{
if ( checkString( s.substr(i,j)) )
{
*********** /*this statement has the error*/ strcpy(suit[k], s.c_str());
This is illegal. The size of an array must be a compile time constant. You might want to disable whatever compiler extension you have enabled that allows it.
Were it legal, you would only be allocating space for pointers. Those pointers would point to random places in memory, so when you do strcpy(suit[k], s.c_str()); you're writing to random memory that you don't own. Surprise. That causes problems.