Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    190

    #include struct { const char...

    #include <stdio.h>

    struct {
    const char *month;
    const char *zodiac;
    int ends;
    } Data[] = {
    { "January", "Capricorn", 19 },
    { "February", "Aquarius", 19 },...
  2. Replies
    8
    Views
    333

    That's very interesting. After reading it through...

    That's very interesting. After reading it through carefully I guess I understand it, but it still seems like magic.
  3. Replies
    3
    Views
    189

    A couple of problems. You should only loop up...

    A couple of problems.

    You should only loop up to i < size - 1 since otherwise 1u<<(i+1) will create 0u on the last iteration.

    You should also start counter at 1, since there will always be at...
  4. Replies
    8
    Views
    333

    Witchcraft! How does that work?

    Witchcraft!
    How does that work?
  5. Replies
    10
    Views
    366

    Just ignore flp. He's proven again and again...

    Just ignore flp.
    He's proven again and again that he doesn't know what he's talking about.
    He's apparently 51 years old but acts like a baby.
    It's pathetic.
  6. Replies
    10
    Views
    366

    For beginners, yes. flp simply doesn't know what...

    For beginners, yes.
    flp simply doesn't know what he's talking about.
  7. Replies
    10
    Views
    366

    %lf allows spaces before it, but you do need to...

    %lf allows spaces before it, but you do need to add some extra spaces to flp's code:


    scanf("%lf%c +%lf =%lf", &a, &y, &b, &c)

    Or, equivalently, but perhaps more readable:


    scanf("%lf%c +...
  8. Replies
    7
    Views
    363

    No you don't. You think they all run as intended....

    No you don't. You think they all run as intended.

    For example, your rand_double function seems to be incorrect.
    You should only seed the rng once in the entire run of the program.
    So you should...
  9. Thread: fgets and size

    by john.c
    Replies
    4
    Views
    258

    Which is also why fgets leaves the newline in the...

    Which is also why fgets leaves the newline in the string. If it's not there (and the stream isn't at eof) then the line was truncated.
  10. Replies
    1
    Views
    235

    For the horizontal swaps: Select a random row...

    For the horizontal swaps:
    Select a random row from 0 to N - 1.
    Select a random col from 0 to N - 2.
    If a[row][col] > a[row][col + 1], swap them.

    For the vertical swaps:
    Select a random row...
  11. That's why I said that I assumed tree.insert()...

    That's why I said that I assumed tree.insert() made a copy of the data.
  12. Maybe something like this: int main() { ...

    Maybe something like this:


    int main()
    {
    ifstream file("data.txt");
    if (!file)
    {
    cerr << "Cannot open input file.\n";
    return 1;
  13. Replies
    4
    Views
    264

    There's no reason to pad lastname to 16 since...

    There's no reason to pad lastname to 16 since firstName, a char array, can start on any byte.
    It's more likely that firstName is padded to 13 so that balance is on an 8-byte boundary.
  14. Thread: Base 16

    by john.c
    Replies
    1
    Views
    235

    I guess your basic problem is that you set i to 0...

    I guess your basic problem is that you set i to 0 every invocation.
    However there's a more general problem. You can't accept an actual hex input since you can only input digits 0 to 9 and not A to...
  15. Instead of this: for (int i = 0;...

    Instead of this:


    for (int i = 0; i < 23;)
    {
    while (company[i].getPrice() != 0)
    {
    i++;
    }
    ...
  16. Thread: Dice

    by john.c
    Replies
    12
    Views
    442

    For some reason you are not able to describe your...

    For some reason you are not able to describe your game clearly.

    Now it sounds like you want to keep rolling until you DON'T get a six. So if you roll a non-6 right away, then that's the value of...
  17. Thread: Dice

    by john.c
    Replies
    12
    Views
    442

    If you want to keep rolling until you get a 6,...

    If you want to keep rolling until you get a 6, summing all the rolls up to but not including the 6, then the average would be 15. That's because the average of the possible values is (1+2+3+4+5) / 5...
  18. They can be both at the same time. You can...

    They can be both at the same time.
    You can ensure you call the function by putting parens around the function name in the call.



    #include <stdio.h>

    void abc(int x) {
    printf("func:...
  19. The head and tail go in ListType. ...

    The head and tail go in ListType.


    typedef struct Node {
    MovieType *data;
    struct Node *prev;
    struct Node *next;
    } NodeType;

    typedef struct{
  20. You need to use a typecast: #define...

    You need to use a typecast:


    #define GPIO_EVB_V2_DEF \
    (struct GPIO_def) \
    { \
    .def_MUX_ADD0 = 33, \
    .def_MUX_ADD1 = 34, ...
  21. I think laserlight didn't look closely enough at...

    I think laserlight didn't look closely enough at the output! :redface:

    You haven't given enough room for the strings. The first string is 36 chars long (including the '\0' at the end). Since...
  22. Replies
    2
    Views
    242

    In main you need to define actual structs, not...

    In main you need to define actual structs, not just pointers to structs.
    Then pass pointers by using the "address-of" operator, &.


    int main() // Don't define argc and argv if you aren't using...
  23. Can you post the full code? In particular,...

    Can you post the full code? In particular, iplib2New.c
    Attaching an input image (in the correct format) would be useful, too.
    Also, you should respond to hamster_nz who responded to your last post....
  24. I assume you mean to use bitwise AND (&), not...

    I assume you mean to use bitwise AND (&), not logical AND (&&).
  25. You should've got warnings with that code. Don't...

    You should've got warnings with that code. Don't ignore warnings.
    You need to use strcpy to set the contents of a string.
    And you should probably pass the struct by pointer.


    #include <stdio.h>...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4