Thread: [Access Violation]: Debug Help

  1. #16
    Registered User
    Join Date
    Jan 2005
    >> what's so wrong about using cstrings in me' code..?!?!?

    Nothing. It's your choice. IMO many C++ programmers (especially beginners) would benefit from learning and using C++ tools, and many just use C versions because their class/instructor/book uses them and they don't know any better. I can see wanting to stay consistent when going through Petzold, but the algorithm above would be simpler, easier and safer (IMO) with C++ tools.

  2. #17
    Join Date
    Aug 2002
    Tucson, Arizona
    One thing I see is this Brain. You need to add + 1 on your new's because strlen does not count the null terminator. E.G
    #include <iostream>
    #include <cstring>
    int main()
        unsigned int getLen = std::strlen("Hello\0");
        return 0;
    This is 5 not 6.

  3. #18
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA

    good catch...

    (so many little nuances to remember..!!! )
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #19
    Registered User
    Join Date
    Jan 2005
    There's also no need to add the null terminator to the string literals. It is there automatically.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary not built with debug info - why?
    By ulillillia in forum C Programming
    Replies: 15
    Last Post: 12-11-2008, 01:37 AM
  2. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 04:00 PM
  3. Debug --> Exceptions in Visual Studio 2005
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-10-2007, 02:12 AM
  4. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM
  5. Ask about Debug Assert Failed
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2002, 11:07 PM