Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.11 seconds.

  1. Replies
    68
    Views
    1,614

    As I've mentioned before: if you create a suite...

    As I've mentioned before: if you create a suite of unit tests and integration tests and run them frequently after making changes, you would detect such bugs sooner rather than later because your...
  2. I think that by invoking g++ to compile my.c,...

    I think that by invoking g++ to compile my.c, my.c is treated as C++ source rather than C source, so name mangling etc comes into effect without extern "C":

    (Compiling C++ Programs)
  3. Replies
    2
    Views
    122

    A few options come to mind: Convert the C++...

    A few options come to mind:

    Convert the C++ code that you apparently found to C.
    Convert the C watch code that you wrote to C++ (if you're lucky it might already be valid C++)
    Write a C...
  4. Replies
    2
    Views
    142

    I feel that unless you're maintaining a library...

    I feel that unless you're maintaining a library and hence can freely add to its namespace, you probably shouldn't add operators to its interface. The reason is that you're dependent on argument...
  5. Here's a test program that I wrote that allocates...

    Here's a test program that I wrote that allocates the same amount of memory as you are trying to allocate on the stack, assuming sizeof(int) == 4:

    #include <stdio.h>

    int main(void)
    {
    int...
  6. Stack size is typically fairly limited, and here...

    Stack size is typically fairly limited, and here you are asking for 32 MB or so in a single call.

    Do they truly represent global state? If so, then perhaps declaring them global is okay. If not, a...
  7. You may need to use uniform initialisation syntax...

    You may need to use uniform initialisation syntax to get that to compile.
  8. From what I see, you only need two grids: the...

    From what I see, you only need two grids: the source grid and the destination grid. After you have performed the computations to populate the destination grid, you print it etc, and then you copy the...
  9. Two options come to mind: Declare normals in...

    Two options come to mind:

    Declare normals in the class definition (which is what you're already doing) then define and initialise it in exactly one source file rather than in the header (i.e.,...
  10. I wrote a quick program to check that I didn't...

    I wrote a quick program to check that I didn't make some silly mistake:

    #include <stdio.h>

    int main(void)
    {
    unsigned char tableID = 101;
    char expected[14]; // NNN_available
    ...
  11. Okay. Temporarily change this: if...

    Okay. Temporarily change this:

    if (strcmp(packetBuffer, expected) == 0) {
    modeAvailable();
    Serial.println("This works!");
    }
    to this:

    if (strcmp(packetBuffer, "101_available") == 0) {
    ...
  12. Replies
    1
    Views
    110

    What about going for permanent jobs instead of...

    What about going for permanent jobs instead of "gigs"? The way I see it, if you're looking around job websites and such for permanent jobs, you might find roles with temporary contracts (which is...
  13. Replies
    3
    Views
    158

    That is what you're trying to do though: make...

    That is what you're trying to do though: make sense of the input according to certain rules. When you're just allowing for one number per line, it is easy to be lax, but if you're trying to interpret...
  14. Replies
    6
    Views
    259

    I saw this over the weekend but got a bit...

    I saw this over the weekend but got a bit distracted and forgot to reply. I was going to say that seems fine to me, although 3 seems to be the same as 1 with the boolean set to false, but maybe you...
  15. Replies
    6
    Views
    259

    Wait, you mean assign a scalar to a matrix, not...

    Wait, you mean assign a scalar to a matrix, not assign a matrix to a scalar, right?

    If so, I think you should go with A since you noted it is more sensible for actual use cases. You shouldn't make...
  16. Replies
    16
    Views
    428

    You're welcome. You should be aware that this...

    You're welcome. You should be aware that this makes your code vulnerable to buffer overflow:

    scanf(" %s", string1);
    To avoid buffer overflow, you should specify the field width:

    scanf(" %49s",...
  17. Replies
    27
    Views
    658

    Coefficients would imply that they are used to...

    Coefficients would imply that they are used to multiply, but you're adding them. As Hodor pointed out, you aren't implementing the equation correctly. You can still use the array+loop method, but...
  18. When I saw that !strcmp(packetBuffer,...

    When I saw that !strcmp(packetBuffer, "101_available")) works but you "Somehow (...) can't get the code correctly to make a correct comparison", and then I see tableID + "_available", it looked like...
  19. This looks like you forgot that string...

    This looks like you forgot that string concatenation in C is not done with the + operator, but rather you either need to append a copy of one string to the other, if there's space, or create an...
  20. Replies
    16
    Views
    428

    That's because you're always reading the first...

    That's because you're always reading the first character, with the remaining characters left in the input buffer. If you want to check that the user entered exactly one character, you should read the...
  21. Replies
    27
    Views
    658

    This is legal syntax, but it doesn't really help...

    This is legal syntax, but it doesn't really help a human being who looks at it:

    float calc_psat (float, float, float, float, float, float);
    float calc_gamma_e(float, float, float, float);
    float...
  22. Replies
    1
    Views
    125

    The simple solution is to provide a second...

    The simple solution is to provide a second parameter for the array size:

    void iter_ints(int arr[], size_t arrSize)
    {
    printf("arrSize %zu\n", arrSize);
    // ...
    }
    I have chosen size_t as...
  23. Replies
    27
    Views
    658

    Yes, I believe you when you say it does work....

    Yes, I believe you when you say it does work. What I am telling you is that according to the code that you posted in post #1, and the declaration of calc_psat that you provided in post #3, version 1...
  24. Replies
    27
    Views
    658

    Then your first code snippet is wrong, despite...

    Then your first code snippet is wrong, despite your assertion that it "works perfectly". In fact, I would expect your first code snippet to either never run at all or run into an infinite loop: you...
  25. Replies
    27
    Views
    658

    In your first code snippet, seed_temp is a float,...

    In your first code snippet, seed_temp is a float, and you pass seed_temp as an argument to calc_psat.

    In your second code snippet, seed_temp is still a float, but you pass &seed_temp as an...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4