Cannot convert 'AnsiString' to 'AnsiString'
-
How to fix the mistake?
Cannot convert 'AnsiString' to 'AnsiString'
in the programme:
AnsiString stroka,vyhod; stroka = Edit1->Text; int l,i,j,k; l=stroka.Length(); vyhod = stroka[1]; AnsiString *vn = new AnsiString[l]; for(i=1;i<=l;i++){ vn[i]=stroka[l-i]; }
Edit1->Text=vn;
-
I don't understand why you're dynamically distributing a set of lines, though, I think you meant
AnsiString *vn = new AnsiString( l ); ^^^^^
instead
AnsiString *vn = new AnsiString[l]; ^^^
provided that class
AnsiString
has a designer with one parameter that sets the number of symbols in the row.And in the next cycle, you should write or
( *vn )[i] = stroka[l-i];
or
vn->operator []( i ) = stroka[l-i];
Although this is not the case, it is not clear that a type of object is being allocated.
AnsiString
Dynamic memory.The cycle itself also raises great doubts, even if it is syntaxically correctly written
for(i=1;i<=l;i++){ ( *vn )[i]=stroka[l-i]; }
Subject
stroke
index changes froml-1
before0
, while at the line addressed by the mysterious name indexvn
index changes from1
beforel
♪ If you want to revert to the line, you should write the cycle correctly.