Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

allocating memory

Name: Anonymous 2008-10-21 23:16

have this pointer
Char *ptr
i allocate memory as
ptr = (char *) malloc (sizeof(char) * 100);
say later on in the program i may or may not need to store more characters so i'll use realloc to assign more memory. How can i find out how much memory is currently assigned to ptr so i cant find if i need to resize it or not.

Name: Anonymous 2008-10-22 19:54

>>4,6,18

~$ touch foo.c
~$ echo "#include <stdio.h>" > foo.c
~$ echo "#include <stdlib.h>" >> foo.c
~$ echo "int main(){" >> foo.c
~$ echo "char * hello;" >> foo.c
~$ echo "hello = malloc(sizeof(char) * 100);" >> foo.c
~$ echo "return 0;}" >> foo.c
~$ echo "" >> foo.c
~$ gcc foo.c -ansi -Wall -o foo&&./foo
~$


>>2
size_t

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List