Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. First-chance exception: Mem violation

First-chance exception: Mem violation

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiondatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boon kian
    wrote on last edited by
    #1

    Hi, can anyone help me with this prob ??? I am at a total lost I have several pointers (using them as matrix) and i have always allocate mem to them using the "new" operator. However i encounter a strange problem with one of them (temp). Whenever my program trys to access the pointer 'temp' up to a location, it would generate an "First-chance exception: 0xC00000005: Access violation" error. an eg of the code is like this: double * temp temp = new double (5000); for (i = 0; i < 5000; i ++) { temp[i] = x*y; } I use breakpoints and see that the index of temp from 1 to 2577 is valid. However when i > 2578 all the values are invalid ("CXX0030: Error: expression cannot be evaluated") and hence causing my program to hit the ""First-chance exception: 0xC00000005: Access violation" error. This seems so strange to me and i am at a lost of what to do...... Can anyone tell me why is it so ?? and how can i solve this problem?? Thank you very much for your kind attention !!

    H 1 Reply Last reply
    0
    • B boon kian

      Hi, can anyone help me with this prob ??? I am at a total lost I have several pointers (using them as matrix) and i have always allocate mem to them using the "new" operator. However i encounter a strange problem with one of them (temp). Whenever my program trys to access the pointer 'temp' up to a location, it would generate an "First-chance exception: 0xC00000005: Access violation" error. an eg of the code is like this: double * temp temp = new double (5000); for (i = 0; i < 5000; i ++) { temp[i] = x*y; } I use breakpoints and see that the index of temp from 1 to 2577 is valid. However when i > 2578 all the values are invalid ("CXX0030: Error: expression cannot be evaluated") and hence causing my program to hit the ""First-chance exception: 0xC00000005: Access violation" error. This seems so strange to me and i am at a lost of what to do...... Can anyone tell me why is it so ?? and how can i solve this problem?? Thank you very much for your kind attention !!

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      Must be: temp = new double [5000]; rechi

      B 1 Reply Last reply
      0
      • H Hans Ruck

        Must be: temp = new double [5000]; rechi

        B Offline
        B Offline
        boon kian
        wrote on last edited by
        #3

        Hi rechi, Really thanx a lot ... I guess i made a silly typo without realizing !! You save my day bk

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups