Search:

Type: Posts; User: anduril462

Page 1 of 20 1 2 3 4

Search: Search took 0.09 seconds.

  1. Both errors are due to the same mistake. ...

    Both errors are due to the same mistake.



    void set_pcap_user_data(pcap_user_data_t *pcap_user_data);
    ...
    pcap_user_data_t *pcap_user_data = malloc(sizeof(pcap_user_data_t) * 1);
    ...
    ...
  2. You get to define the data type you pass in as...

    You get to define the data type you pass in as the user argument to pcap_loop, and thus what gets passed to process_packet. You can just define a struct that contains activity list and whatever else...
  3. Replies
    2
    Views
    5,500

    Pro tip: use tags for code. It will display...

    Pro tip: use
    tags for code. It will display in a fixed-width font and automatically do syntax highlighting (so paste your code as plain text). This will be much more readable.

    As for your...
  4. Replies
    4
    Views
    7,026

    First, read up on implementation-defined,...

    First, read up on implementation-defined, unspecified and undefined behavior. I find the following a good summary: Question 11.33.

    The use of (void *) is a type cast, just like (int). It changes...
  5. Replies
    4
    Views
    7,026

    You should use %p for printing the value of a...

    You should use %p for printing the value of a pointer. You should also cast the pointer values you're printing to (void *). So your code should look like

    printf("%p, %p, %p, %p, %s\n", (void *)...
  6. The way you have it defined, you can only have 2...

    The way you have it defined, you can only have 2 levels of nesting. This means there's no need to do this recursively. You could simply do this with nested loops (while loops or for loops).

    The...
  7. Replies
    8
    Views
    11,195

    In general, that would be considered good style. ...

    In general, that would be considered good style. I like when each function in my code reads like a summary in English of what it does. Obviously this doesn't apply to the inner-most functions.
    ...
  8. Replies
    2
    Views
    3,290

    Please post your current code, neatly formatted...

    Please post your current code, neatly formatted and indented, in
    tags so we can help you find your problem.
  9. Replies
    9
    Views
    9,883

    What you seem to be asking is would the size of...

    What you seem to be asking is would the size of an uninitialized array be different from the size of an initialized one. Try this program, and see what it prints out:


    #include <stdio.h>

    ...
  10. Replies
    8
    Views
    5,865

    Looks good, but a few things you can do to clean...

    Looks good, but a few things you can do to clean it up:


    malloc can return NULL if it fails (see man page), so you should check for that. If you don't and it returns NULL, you will end up...
  11. Replies
    3
    Views
    3,010

    Tim got your problem fixed, but I'd like to point...

    Tim got your problem fixed, but I'd like to point out a few other improvements:


    Getting a good editor/IDE with syntax highlighting and auto-indent features is very helpful. In fact, an...
  12. For the first question: you could always print...

    For the first question: you could always print the value of howmany immediately after you assign i to it, to double check.

    I'm going to flip your second question around on you, to make you think...
  13. I think you misunderstood Tim. The calculation...

    I think you misunderstood Tim.

    The calculation of NUM_ITEMS is correct: the size of the entire array divided by the size of a single element.

    What Tim is saying is that NUM_ITEMS is not the...
  14. Replies
    2
    Views
    2,855

    A linked list, generally speaking, is a good data...

    A linked list, generally speaking, is a good data structure to hold a list of things that can grow (or shrink) significantly in size. However, a dynamically allocated array can grow and shrink...
  15. Replies
    4
    Views
    3,227

    Posting the requirements for the assignment and...

    Posting the requirements for the assignment and contents of your username files would make it easier for us to help you.

    General tips, and bug I can see just by reading the code:


    Formatting....
  16. Replies
    28
    Views
    15,524

    I'm not sure what you mean by "if I took this...

    I'm not sure what you mean by "if I took this function and place it in main". C doesn't really support functions inside functions. Did you mean call this function from main?

    Perhaps go back and...
  17. Replies
    28
    Views
    15,524

    Yeah, check out the link stahta01 provided. A...

    Yeah, check out the link stahta01 provided.

    A few notes:


    No semicolon at the end of the function definition (line 11).
    You do need parentheses at the end of a funciton definition.
    Any...
  18. Thread: bmp files

    by anduril462
    Replies
    1
    Views
    2,564

    If you can use fread, you can use fwrite. ...

    If you can use fread, you can use fwrite. They're virtually identical, except that one reads and the other writes. Same basic parameters, same order: pointer to data, item size, number of items,...
  19. Replies
    28
    Views
    15,524

    Forums are not the best place for lecture-level...

    Forums are not the best place for lecture-level teaching. They better serve specific questions and help with specific issues. Also, if your prof is giving 4 weeks for this assignment, they may have...
  20. Replies
    28
    Views
    15,524

    Can you post what code you have so far? You...

    Can you post what code you have so far? You should be able to handle several of the requirements without using pointers or pass-by-reference. It would be good to see your attempt at the...
  21. Replies
    28
    Views
    15,524

    I'm not really clear what the assignment is...

    I'm not really clear what the assignment is asking and where pass by reference fits into that. Regardless, here's a summary of how it works:

    Everything in C is, in a sense, pass-by-value. Take...
  22. Replies
    1
    Views
    2,830

    Next time, please post your code in tags. It...

    Next time, please post your code in
    tags. It should look like this:


    FILE *image =fopen ("file.txt", "rt");
    fget(work.bmp, sizeof(work.bmp)+1, imagine);

    Some things I can see from the two...
  23. Thanks. Sorry if I wasn't clear. I'm teaching...

    Thanks.

    Sorry if I wasn't clear. I'm teaching some intro courses, but pretty much all the courses, including advanced ones, are C++ (though honestly, the bar is not very high at this school, so...
  24. Recommended C++ compiler and IDE for Windows

    Hey all, been a while :D. Work and life in general has kept me away from this forum, but I'm hoping I can ply you all for some advice.

    I'm wondering if anybody can recommend a good, modern IDE...
  25. Yes, you should set it to NULL. When you use...

    Yes, you should set it to NULL.

    When you use malloc, there is no guarantee what value is in the memory you just allocated. It could be anything. That means that if you add new_patient to the end...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4