Thread: Memory Allocation (dare!)

  1. #1

    Memory Allocation (dare!)

    i have some problem ...
    we have a function like below
    int how_many( int *p ){
    how can we know the size of allocated memory for this pointer

    for example in samewhere
    int *p=(int *)malloc(rand()*sizeof(int));

    there is a func. in VC named "_msize "
    but i want to learn how it works

    have a nice day

  2. #2
    Registered User Sargnagel's Avatar
    Join Date
    Aug 2002
    Just use Google or the Microsoft Developer Network to look up the function:

  3. #3
    Registered User
    Join Date
    Apr 2002
    The _msize function will return the size in bytes of the allocation. Remember if you are actually looking for the # of elements you must divide out by the size of a single element.

  4. #4

    not exactly...

    i know _msize finds ...
    but i want to write my own function

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory allocation question
    By dakarn in forum C Programming
    Replies: 11
    Last Post: 12-01-2008, 11:41 PM
  2. Dynamic memory allocation...
    By dicorr in forum C Programming
    Replies: 1
    Last Post: 06-24-2006, 03:59 AM
  3. C memory allocation to c++
    By markucd in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2005, 05:56 AM
  4. Understanding Memory Allocation
    By Ragsdale85 in forum C Programming
    Replies: 7
    Last Post: 10-31-2005, 08:36 AM
  5. memory allocation ptr to array? how?
    By kokopo2 in forum C Programming
    Replies: 8
    Last Post: 09-01-2005, 05:06 PM