Thread: memory leak in the code?

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I just want to learn in what situations using dynamic allocated array is better than using vector? In my experience, I always think vector is better than dynamic allocated array for a couple of reasons. :-)
    Daved and I agree with you.

    EDIT:
    Consequently, the only situation when using a dynamically allocated array is better than using a vector is when you cannot use a vector for some reason. Such reasons range from the dictates of a professor/teacher or management to the limitations of the compiler that you have to use (which again could be due to the whim of a professor or management).
    Last edited by laserlight; 01-13-2008 at 03:24 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Agree, laserlight!


    My question is answered.

    Quote Originally Posted by laserlight View Post
    Daved and I agree with you.

    EDIT:
    Consequently, the only situation when using a dynamically allocated array is better than using a vector is when you cannot use a vector for some reason. Such reasons range from the dictates of a professor/teacher or management to the limitations of the compiler that you have to use (which again could be due to the whim of a professor or management).

    regards,
    George

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I can't think of a specific situation where a dynamically allocated array is better than a vector.
    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. #19
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Agree, Elysia. Vector is invented to replace dynamic array. But in some legacy code, we have to maintain. :-)


    Quote Originally Posted by Elysia View Post
    I can't think of a specific situation where a dynamically allocated array is better than a vector.

    regards,
    George

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, in that case, a dynamic array isn't better, instead we are limited to a dynamic array unless you rewrite that 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.

  6. #21
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks Elysia,


    Quote Originally Posted by Elysia View Post
    Well, in that case, a dynamic array isn't better, instead we are limited to a dynamic array unless you rewrite that code.
    Agree. :-)


    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory leak
    By rahulsk1947 in forum C Programming
    Replies: 2
    Last Post: 11-11-2007, 01:27 PM
  2. Memory leak with detached pthreads - how to free?
    By rfk in forum Linux Programming
    Replies: 2
    Last Post: 08-17-2007, 06:50 AM
  3. Memory leak by simple char
    By Ktulu in forum C++ Programming
    Replies: 42
    Last Post: 11-05-2006, 01:59 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM