Access violation Float32

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
julia_h
Posts: 2
Joined: Mon, 2017-07-17, 18:13

Access violation Float32

#1 Post by julia_h »

Hello,

I am trying to write some values in an Float32 variable, but I always get an Visual studio exception saying "Access violation writing location 0x000...". I tried it the following way:

Code: Select all

Float32* value;
Vector3 vector = Vector3(1, 1, 1);

value[0] = vector.x;
value[1] = vector.y;
value[2] = vector.z;
Vector3 is a datatype from MeVisLab, including MLdouble values. I know, that I propably need to convert the MLdouble values into floats or something like this, but the Visual studio exception sounds, like there is a problem with the access to the Float32 variable. Does anyone know how it is possible to save more than one value in the Float32?

Thank you in advance!

Best regards,
Julia

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Access violation Float32

#2 Post by Michael Onken »

Hi,

you do not reserve memory for your Float32 value... Try "Float32 value[3];" as your first line, or use the new operator if you actually want to place the value variable on the heap.
Not really a DCMTK question, by the way ;)

Best,
Michael

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Access violation Float32

#3 Post by Jan Schlamelcher »

Don't let him teach you bad practice (new operator), use an std::vector!

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Access violation Float32

#4 Post by Michael Onken »

:evil: :lol:

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Access violation Float32

#5 Post by Jan Schlamelcher »

:wink:

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest