type
TS = record
FN, RN: String;
end;
var
Sy: array of TS;
S: ^String;
...
SetLength(Sy,2);
begin
Sy[0].FN:='123';
Sy[0].RN:='bad';
Sy[1].FN:='345';
Sy[1].RN:='000';
end;
...
S := @(Sy [i].FN);
How to imitate Pascal logic in C language? Next code does not work:
typedef struct
{
char FN[256];//char FN[] /*isn't allowed by compiler*/
char RN[256];//char RN[] /*isn't allowed by compiler*/
} TS;
TS Sy[];
main()
{
Sy=malloc(2*sizeof(TS));
strcpy(Sy[1].FN,"1234");
}
QUESTION 1
I get compiler error error C2106: '=' : left operand must be l-value
. What should I do to imitate Pascal logic in case of SetLength?
QUESTION 2
How to specify a string of unknown size (Ansistrings is Pascal). When I set char FN[];
I get error error C2229: struct '<unnamed-tag>' has an illegal zero-sized array
. What should I do to imitate Pascal logic in case of Ansistring?