I figured a good method would be to follow pointers to the end of the queue and then deallocate backwards, but my experience with C++ is severely lacking. I also forgot to mention that the "empty...
Type: Posts; User: RobJ
I figured a good method would be to follow pointers to the end of the queue and then deallocate backwards, but my experience with C++ is severely lacking. I also forgot to mention that the "empty...
Thanks for the replies
This is only a queue of pointers to other data structures, so given that these structures may be needed elsewhere I'm requiring explicit deallocation.
Thanks for the...
Hi,
I'm trying to create a simple queue structure and am running into problems when I try to empty the queue. Here's the relevant pieces of code:
typedef struct queue_item {
void...
Yikes, I didn't realise it could be done that simply. Thank you both for the help. :)
I'm moving data from "node" to "destination", so my original code should be correct.
What do I have to free after moving? If I free "destination" after I overwrite it with "node" then surely...
OK, thanks, but if I change it to this:
//Copy the entire node as a block of memory into the new position
node = (TreeNode *) memmove(destination, node, sizeof(TreeNode));
//The destination...
I have the following method that I use to replace one node of a binary tree with another:
int inttree_replace(TreeNode *destination, TreeNode *node)
{
//Return false if either node is invalid...
Cool, I'll make those changes. Thanks very much for the info.:)
Or you could use a more GUI-oriented language such as C# if you're looking to create a snazzy interface. There's no sense (IMO) putting all that effort in to try and generate a C GUI when the...
Okay, I seem to have got a working method, although it does seem a little long-winded for something as simple as string concatenation:
int c,r;
char *str;
char tmp[10];
//The initial size...
Ah, that'd be a stupid mistake then. I was copying the code from one screen to another and obviously messed up.
Oh okay, that makes some kind of sense. I apologise for my ignorance: I'm...
Okay, I'm stumped. Can anyone see what's wrong this bit of code?:
int c, r , t;
char *str;
char[10] tmp;
for (r=0; r<array->rows; r++) {
for (c=0; c<array->columns; c++) {
t =...
That is most unhelpful. I eventually 'solved' the problem by adding another int field called elements that holds the product of the number of rows and columns. If elements == rows*columns then I...
Note that <limits.h> defines constants you may find useful for this purpose, namely "FLT_EPSILON" and "DBL_EPSILON". These are the smallest number 'x' such that 1.0 + x != 1.0 for floats and doubles...
Oh okay, thanks for the very speedy reply. :)
Unfortunately that doesn't completely solve my problem. To expand on the exercise I have a function with a signature like this:
int...
Hi all, I'm just starting to get to grips with C programming and am having a little trouble using pointers and structures. I'm working through a simple exercise for practice and have the following...