Search:

Type: Posts; User: lucaspewkas

Search: Search took 0.01 seconds.

  1. Thank you :) It's a big help

    Thank you :) It's a big help
  2. ummm, well I'm willing to wait, but I'll work it...

    ummm, well I'm willing to wait, but I'll work it out myself if you don't want to, was just trying to save a bit of time...
  3. But wouldn't that convert the entire string after...

    But wouldn't that convert the entire string after that element? I need it to stop at header[8]. And also how do you point to an element within an array? Because if I just put header[4] as the...
  4. Extracting certain bits from sequence of bits

    OK so I have a char* variable, which contains the header for a particular packet. There are various fields in this packet but the header isn't split up into different variables. So my question is,...
  5. Replies
    3
    Views
    1,166

    cool thanks, that worked :)

    cool thanks, that worked :)
  6. Replies
    3
    Views
    1,166

    trouble with pointers

    OK once again, pointers are causing me headaches

    I'm trying to get a word from a file, and write that into a buffer. The buffer is malloced like so:

    char *buf = malloc( INIT * sizeof(char) );...
  7. Replies
    4
    Views
    5,151

    yeah, it was all wrong, I need it to be a FILE*...

    yeah, it was all wrong, I need it to be a FILE* anyway...:)
  8. Replies
    4
    Views
    5,151

    Thanks thats all I wanted to do, then I just...

    Thanks thats all I wanted to do, then I just malloced inside the function. Haven't used global variables much, didn't think about trying to store a non-constant value :)
  9. Replies
    4
    Views
    5,151

    initializer element is not constant

    I'm trying to define a char* global variable (is this bad practice?) but keep getting an error message "initializer element is not constant"

    the code is as follows:


    char* inputfile = malloc(...
  10. Replies
    5
    Views
    62,717

    Yeah that's what I thought, but when I run it...

    Yeah that's what I thought, but when I run it through gdb, if I put a string longer than MAXBUF in, it WILL get cut-off automatically, but the next time the while loop comes around, instead of...
  11. Thread: heap sort

    by lucaspewkas
    Replies
    6
    Views
    2,001

    Yep, pretty easy to guess I suppose, damn sorting...

    Yep, pretty easy to guess I suppose, damn sorting project took me ages. Still, I learned a hell of a lot from it so it's not all bad.
  12. Replies
    5
    Views
    62,717

    fgets in while loop

    OK I know I've posted something like this before but I now have a slightly different problem.
    I am reading in input to a buffer line by line (using fgets) and then putting the buffer into an array...
  13. Thread: heap sort

    by lucaspewkas
    Replies
    6
    Views
    2,001

    Don't worry, I worked everything out, yay! For...

    Don't worry, I worked everything out, yay!

    For anyone that was interested, instead of doing:


    child = 2*parent + width

    I just did:
  14. Thread: heap sort

    by lucaspewkas
    Replies
    6
    Views
    2,001

    Thanks, that cleared up some things, but I still...

    Thanks, that cleared up some things, but I still cannot find the child nodes. The children appear at 2*parent+1 in a heap as far as I know, but when parent is void* (or unsigned char*) rather than...
  15. Thread: heap sort

    by lucaspewkas
    Replies
    6
    Views
    2,001

    heap sort

    I am trying to write a heap sort function using the prototype:



    void
    heap_sort(void *base, size_t nel, size_t width, int(*compar)(const void *, const void *));

    where base is a pointer to...
  16. Replies
    11
    Views
    1,853

    Thanks guys, it's all working. Guess it isn't...

    Thanks guys, it's all working. Guess it isn't really that hard if you think about it :)
  17. Replies
    11
    Views
    1,853

    Taking only first 100 chars of a string

    Is there a function that will, if a string has more that 100 chars in it, just cut off anything after the 100th char?

    If not, any hints on how to start writing this function myself?

    Thanks
  18. Replies
    2
    Views
    1,253

    Thankyou so much, you have no idea how much this...

    Thankyou so much, you have no idea how much this was @%*#ing me :)
    It all works now, guess I need to learn a bit more about malloc and pointers, maybe another day...
  19. Replies
    2
    Views
    1,253

    string arrays

    I am having trouble writing input from stdin to an array of strings in C. Forgive me if this is trivial but I really hate dealing with strings, they seem easy but never work for me. Here is some...
Results 1 to 19 of 19