Search:

Type: Posts; User: anduril462

Page 1 of 20 1 2 3 4

Search: Search took 0.03 seconds.

  1. Replies
    2
    Views
    470

    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...
  2. Replies
    4
    Views
    1,315

    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...
  3. Replies
    4
    Views
    1,315

    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 *)...
  4. 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...
  5. Replies
    8
    Views
    1,288

    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.
    ...
  6. Replies
    2
    Views
    725

    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.
  7. Replies
    9
    Views
    1,057

    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>

    ...
  8. Replies
    8
    Views
    1,107

    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...
  9. 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...
  10. 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...
  11. 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...
  12. Replies
    2
    Views
    602

    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...
  13. Replies
    4
    Views
    620

    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....
  14. Replies
    28
    Views
    2,320

    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...
  15. Replies
    28
    Views
    2,320

    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...
  16. Thread: bmp files

    by anduril462
    Replies
    1
    Views
    321

    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,...
  17. Replies
    28
    Views
    2,320

    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...
  18. Replies
    28
    Views
    2,320

    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...
  19. Replies
    28
    Views
    2,320

    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...
  20. Replies
    1
    Views
    403

    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...
  21. 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...
  22. 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...
  23. 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...
  24. > If i don't initialize my diva and divb arrays...

    > If i don't initialize my diva and divb arrays to 0 I keep getting strange numbers! why?

    Because that is just the way C is. Local variables are uninitialized by default1.

    > Is there any way...
  25. Replies
    5
    Views
    830

    General notes first: Neatness matters! If...

    General notes first:


    Neatness matters! If code is easy to read, it's harder to make mistakes and easier to find and fix them when you do. On the flip side, messy code can make debugging more...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4