using malloc method to hold the converted data to string/char array

This is a discussion on using malloc method to hold the converted data to string/char array within the C Programming forums, part of the General Programming Boards category; malloc, free, and snprintf...

  1. #16
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    malloc, free, and snprintf

  2. #17
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    u dont have to rebuild them, u can find the code for that on the web, just recompile it with your native compiler.

    ssharish

  3. #18
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    I've searched around on google and found out that it's not recommended to use dynamic memory allocation in mikroC due to hardware memory limitations. Thanks for your help anyway.
    Last edited by stanlvw; 12-16-2007 at 10:22 PM.

  4. #19
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    I got this link from a book. You can get the source code for Standard C Library from here.

    http://sourceware.org/newlib/

    ssharish

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Quote Originally Posted by stanlvw View Post
    Elysia: What do you mean 5 chars is not enough to hold an uint? My uint would have at max 10 bits resolution.
    cpjust: Thanks for your time on the casting issues. I copied the example code from cplusplus.com's explanation of malloc(). Also, stdio.h and stdlib.h are ignored on purpose in mikroC development suite, I think. Hence why I didn't include them.
    I was referring to that the max number an uint can hold is 0xFFFFFFFF - in decimal, that is 4 294 967 295. I read... 10 digits. And since one byte is required for each digit in a string, that means the safest lowest amount of memory to allocate is 10 bytes for the numbers + 1 for '\0'. A few extra bytes of memory doesn't hurt that much I think.
    It's better to be safe than sorry, especially if something bad happens or if you need higher numbers in the future.
    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.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Line of data input method
    By larry_2k4 in forum C Programming
    Replies: 2
    Last Post: 04-29-2009, 12:34 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. how do you input data from a file into an array?
    By jorgejags in forum C Programming
    Replies: 5
    Last Post: 11-03-2008, 02:48 PM
  4. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  5. Replies: 2
    Last Post: 07-11-2008, 08:39 AM

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