Search:

Type: Posts; User: RobJ

Search: Search took 0.00 seconds.

  1. Replies
    5
    Views
    1,847

    I figured a good method would be to follow...

    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...
  2. Replies
    5
    Views
    1,847

    Thanks for the replies This is only a queue...

    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...
  3. Replies
    5
    Views
    1,847

    Simple Queue Question

    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...
  4. Thread: Tidying up memory

    by RobJ
    Replies
    6
    Views
    1,405

    Yikes, I didn't realise it could be done that...

    Yikes, I didn't realise it could be done that simply. Thank you both for the help. :)
  5. Thread: Tidying up memory

    by RobJ
    Replies
    6
    Views
    1,405

    I'm moving data from "node" to "destination", so...

    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...
  6. Thread: Tidying up memory

    by RobJ
    Replies
    6
    Views
    1,405

    OK, thanks, but if I change it to this: //Copy...

    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...
  7. Thread: Tidying up memory

    by RobJ
    Replies
    6
    Views
    1,405

    Tidying up memory

    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...
  8. Replies
    6
    Views
    1,248

    Cool, I'll make those changes. Thanks very much...

    Cool, I'll make those changes. Thanks very much for the info.:)
  9. Replies
    5
    Views
    1,751

    Or you could use a more GUI-oriented language...

    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...
  10. Replies
    6
    Views
    1,248

    Okay, I seem to have got a working method,...

    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...
  11. Replies
    6
    Views
    1,248

    Ah, that'd be a stupid mistake then. I was...

    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...
  12. Replies
    6
    Views
    1,248

    Simple string question

    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 =...
  13. Replies
    6
    Views
    2,257

    That is most unhelpful. I eventually 'solved' the...

    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...
  14. Thread: Declare float

    by RobJ
    Replies
    10
    Views
    1,840

    Note that defines constants you may...

    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...
  15. Replies
    6
    Views
    2,257

    Oh okay, thanks for the very speedy reply. :) ...

    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...
  16. Replies
    6
    Views
    2,257

    Pointers to structures - Beginner question

    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...
Results 1 to 16 of 16