| re: Memcpy problem! Plz help me, I'm totally stuck here :(
Hi Paul,
you need to take an address of varValue.dblVal instead of trying to cast it
to (double*), to do this change second parameter from
(double*)varValue.dblVal, to &varValue.dblVal.
I believe that you should do the same for int and long.
You can replace memcpy with:
*((double*)(((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value) =
varValue.dblVal;
Good luck,
-- Vladimir Khvostov
"Paul Schouten" <vincent_schouten@yahoo.com> wrote in message
news:41d94caf$1$6219$e4fe514c@news.xs4all.nl...[color=blue]
> Hey,
>
> Currently im working on a project where a dynamic database is created in
> memory, the database can be of any size both in the amount of rows aswell[/color]
as[color=blue]
> in the amount of columns. The database is filled with data from a[/color]
mdb-file.[color=blue]
> During this process i use the following lines to copy the data from the
> db-file into memory:
> case dbInteger:
> (((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value = new
> int;
>[/color]
memcpy((int*)(((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value,[color=blue]
> (int*)varValue.intVal, sizeof(int));
> case dbLong:
> (((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value = new
> long;
>[/color]
memcpy((long*)(((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value,[color=blue]
> (long*)varValue.lVal, sizeof(long));
>
> Im sure there are many other ways to do this, some of which probably much
> more efficient and effective, however i've decided (by lack of knowledge
> about other methods) to use this one.
> Now this all works just fine but when i try this on the double-type i get[/color]
an[color=blue]
> "type cast: cannot convert from 'double' to 'double *'" error message.....
>
> Can someone plz help me with this, i have no idea why this is[/color]
happening!!!![color=blue]
>
> This is the code for the double: (nearly the same as the ones above except
> for the types)
> (((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value = new double;
>[/color]
memcpy((double*)(((MEMFIELD*)(((MEMROW*)(mRec->Table))[x]).Field)[y]).Value,[color=blue]
> (double*)varValue.dblVal, sizeof(double));
>
> Cheers,
>
> Paul
>
>[/color] |