I would be doing this once when the program stops. How could I take a pointer to the first function argument if I don't know the function I'm in?
Type: Posts; User: donthate
I would be doing this once when the program stops. How could I take a pointer to the first function argument if I don't know the function I'm in?
I'm writing a program that involves traversing the stack, and I need to find out how to locate the current base pointer without information about the current function. I know there is a way to do it...
Great, thank you!! :)
I was wondering about how realloc is implemented: so lets say you originally had an n-byte array malloc'ed and you want to now have a 2n-byte array. Then realloc can increase the bytes available for...
So what if s1 was malloc'ed 4 characters and is "abcd" and s2 is "efg." Then how is the space allocated and added to s1 to be able to fit in s2?
Oh ok-even if the arrays were malloc'ed?
So how exactly does strcat work?
Got it, thank you for clearing that up!
Also, another question involving strcat-when you use strcat(s1,s2) it appends s2 to s1 right? but then if I try to change s2, then the change will be...
Hey guys,
In my program I am gradually clearing c-strings in an array by setting array[0] to '\0'.
Does this free the memory too? I didn't think that it would but then if I clear one of the...
Update: after thinking about what you said, I fixed the leak by using strcopy instead. I think everything is working correctly. The only thing is that according to valgrind I apparently allocate...
Ok that makes a lot of sense.
One question though: since I'm allocating space for each of the storefrag elements that is not equal to the size allocated for tfrag, when I use strdup to return a...
Thanks for your replies. I realize it's hard to help without some code, so here is the relevant bit. I
I want to call ReadAndStore to read a file, allocate some memory to store the file contents,...
I guess the reason I wanted to allocate separately is because I can't pass in array because I don't know the sizes of the arrays I want until I get into that function. If I move that part of the...
Hi there,
I'm writing a function that
- allocates memory for ptarray, a **char with enough space for n *char's using malloc
- as it reads a file, allocates an appropriate amount of space for the...