CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    144

    float* to float access violation

    Hi, I'm trying to do a simple conversion like so -

    float *a;
    *a = 5;
    float b = *a; // access violation reading location 0x00000020


    How can I do this properly?

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: float* to float access violation

    a is uninitialized.

    float f;
    float* a = &f;

    or

    float* a = new float;

    Then
    *a = 5.0;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured