"wizard" <> writes:
> Uzytkownik "Ben Bacarisse" <> napisal w wiadomosci
> news:...
>> "wizard" <> writes:
<snip>
>>> I would like to write/read geometry of simple 2D objects (shapes but with
>>> holes) to Sqlite blob field.
>>> I delivered a little test snippet - what I,m doing wrong.
>>>
>>> Maybe my data structure as below is wrong
>>> typedef struct points
>>> {
>>> long numPoints;
>>> double *x;
>>> }Points;
<snip>
>> struct points {
>> long int num;
>> double data[];
>> };
>>
>> struct points blob_ptr;
>> blob_ptr = malloc(sizeof *blob_ptr + 2 * N * sizeof *blob_ptr->data);
>>
>> (I multiplied by 2 because I assume you need 2 doubles for each
>> point.)
>>
>> If you can't use the device, you should search for the "struck hack".
>> In older C you need to have an array of size 1, and adjust things
>> accordingly.
>>
>> --
>> Ben.
Best not to quote sig blocks even though mine is short. In fact it is
best to cut out the parts that you are not commenting on but leaving
enough for context.
<snip>
> But how a can declare a string to store diffrent lenght strings (e.g
> "100/15", "1", "1111155668989" etc.)
> not to loose memory (not static text) I tried as above but a can't compile
> (under VC 6.0)
> - variable text
>
> struct points {
> long int num;
> double data[];
> char text[];
> };
In VC I don't you can use the [] syntax (I know little about VC but it
is a C99 construct and VC is C90). Even if you could, you can't have
more than one such array in a struct and it has to be the last member.
It is probably better to re-think how you are string the data in this
database. DBs are good at storing text, so I don't see why you've now
added a char array to your "blob".
--
Ben.
|