Thread: converting string to integers

  1. #16
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Doing a realloc for every char in the string is REALLY bad coding practice.
    Any suggestion how to create dynamic array such as Stack(with pop, push, shift, and unshift) efficiently?

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Use a predetermined size, then keep track of it. If allocation exceeds currently allocated buffer, then double the buffer using realloc and remember new size.
    The idea to is to call realloc as little as possible, while still keeping the default size as low as possible (otherwise your program would be a memory hogger).
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting a string of words into correct cases
    By BigFish21 in forum C++ Programming
    Replies: 2
    Last Post: 05-26-2008, 12:53 AM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM