unknown error!

This is a discussion on unknown error! within the C++ Programming forums, part of the General Programming Boards category; hi, can some body say what is this error Unhandled exception at 0x64f3797f (msvcp90d.dll) in Exercise.exe: 0xC0000005: Access violation writing ...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103

    unknown error!

    hi,
    can some body say what is this error
    Unhandled exception at 0x64f3797f (msvcp90d.dll) in Exercise.exe: 0xC0000005: Access violation writing location 0x6d696873.
    I use Visual studio 2008 to compile.
    Attached Files Attached Files

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You had the exact same problem in your previous thread.

    Code:
    string newPassword;
    ...
    fread(&newPassword, sizeof(string), 1, fp);
    You can't cast a string's address to void* and expect something to come out of it. What is the reason that you are attempting such low level input? You might use a char* instead or read in junks to char* and append them to string or something like that.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    It means you did something very bad.
    This code in itself is very, very bad.
    You mix a lot of C and C++.
    I believe the cause of the error is this line:
    Code:
    fread(&newPassword, sizeof(string), 1, fp);
    Never, EVER use C-style functions to read directly into a C++ object.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    thanks
    I always forget to correct this

  5. #5
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    thanks
    I always forget to correct this

  6. #6
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    what should I use instead of fread();

  7. #7
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    You mix a lot of C and C++.
    I'm trying to change a code that I wrote before in C to C++. in fact I'm practicing C++ by this.

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    > Unhandled exception at 0x64f3797f (msvcp90d.dll) in Exercise.exe: 0xC0000005: Access violation writing location 0x6d696873.
    Since the address in question consists entirely of byte values which are printable, in this case "mihs", look for anywhere in your code where that string (or it's reverse) was typed in by you, or exists as string data in your code.

    Basically, your string overwrote a pointer, then you tried to dereference it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    I used a different approach.
    The error occured when exit was called, and it was inside the destructor of std::string. That tells me that there was some corruption in a global std::string (since there was no std::string in main).
    I found only one, so I took its address and compared it to the address of "this" inside the destructor of std::string and sure enough - they matched.
    So I set a data breakpoint on that address, and VS kindly breaked when the contents of the std::string was corrupted. It was inside fread, so I used the call stack to go back to the calling function and found the source of the error.

    And as for what you should use - streams! You already use them in one part of the code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    I removed fread and use ifstream inClientFile instead, Now problem solved
    thank you Elysia, Salem, anon

    I hope your advance advices help me through learning C++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21