Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.11 seconds.

  1. If you want to initialise, you can do so with an...

    If you want to initialise, you can do so with an aggregate:

    struct confTimer radioT = {"B0", "up_down", 4455};
  2. Replies
    2
    Views
    151

    It sounds like you need to do some debugging: put...

    It sounds like you need to do some debugging: put aside the rest of your code for now and just check that your loop to find "the row that includes the maximal element" is correct. When you're...
  3. That's because you end up comparing pointers...

    That's because you end up comparing pointers rather than the string content. Use strcmp instead, or take advantage of the characteristics of the expected string data (it always starts with a 'B'...
  4. You might want to recall that string literals are...

    You might want to recall that string literals are delimited by double quotes, not single quotes.
  5. By the way, I'm assuming that it was merely for...

    By the way, I'm assuming that it was merely for illustration, but you should be aware that besides being syntactically incorrect due to the omission of the type and the missing semi-colon, your code...
  6. In your example, the array is sorted. For actual...

    In your example, the array is sorted. For actual input, is the array guaranteed to be sorted? If it is, then a simple loop from the first to the last element, stopping at the first element that...
  7. During the Cretaceous period, variables had to be...

    During the Cretaceous period, variables had to be declared at the start of blocks. It was forbidden to mix declarations and non-declarative code. MSVC evolved very slowly, so it is quite possible...
  8. Okay, to avoid any possible misreading of your...

    Okay, to avoid any possible misreading of your code, I compiled this with gcc 9.3.0 with the -Wall -pedantic -std=c99 flags:

    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>


    int...
  9. Are you sure you managed to compile it with your...

    Are you sure you managed to compile it with your compiler under Code Blocks? The code has compile errors, e.g., you use the variable named V_plasmazone without declaring it. Furthermore, MSVC makes...
  10. I believe awsdert has tried Check...

    I believe awsdert has tried Check
  11. Replies
    2
    Views
    170

    I would focus on these lines first: ...

    I would focus on these lines first:

    LibraryType* library = malloc(sizeof(LibraryType));
    BookCollectionType* book = malloc(sizeof(BookCollectionType));

    addBook(book, "The Hunger Games", 2012,...
  12. Replies
    10
    Views
    384

    1. How does it not work? You need to be...

    1. How does it not work? You need to be absolutely clear what your code is supposed to do and why you concluded it does not work.

    2. Trace through your code step by step. This is with reference to...
  13. Replies
    10
    Views
    384

    You can refer to my previous post: The for...

    You can refer to my previous post:

    The for loop itself should be search the array of numbers to check if the number the user entered is equal to any one of them. If it is, that's when you announce...
  14. Oh, I just realised that you have: ...

    Oh, I just realised that you have:

    ProductCollectionType* productCollection[MAX_PROD];
    This looks strange: I would expect MAX_PROD to refer to the maximum number of products, not the maximum...
  15. If we look at addProduct, it looks like it...

    If we look at addProduct, it looks like it doesn't really add a product to the production collection. Rather, it iterates over the existing product collection and sets every existing product to the...
  16. Was that a way to subtly discourage copying the...

    Was that a way to subtly discourage copying the example by introducing a syntax error? :D

    I rarely use the comma operator because as you observed I too find that "evaluating many instructions in...
  17. Replies
    1
    Views
    200

    1. If the function is not meant to return a value...

    1. If the function is not meant to return a value then declare it to have void return type.

    2. Yes.
  18. Replies
    12
    Views
    322

    Then you're just over-complicating this whole...

    Then you're just over-complicating this whole thing. No, you don't declare the array in main because there is no array in main, only a pointer. The function that main calls handles everything, and...
  19. Replies
    12
    Views
    322

    If you're talking about initialisation in the...

    If you're talking about initialisation in the strict sense of the term, then no: you must initialise at the point of declaration.

    However, it looks like you're talking about initialisation more...
  20. You can use static non-member functions in C++...

    You can use static non-member functions in C++ exactly as you do in C, except that the conventional approach in C++ is to use non-member functions defined within an unnamed namespace instead. Either...
  21. Replies
    4
    Views
    159

    Look at this line: uc=n%10; So, uc is the...

    Look at this line:

    uc=n%10;
    So, uc is the current "last digit" or current "right-most digit" or current "least significant digit" of the number. If you return uc in the body of the loop, you...
  22. Replies
    4
    Views
    159

    Notice that in your C++ code you're printing each...

    Notice that in your C++ code you're printing each digit in the loop, whereas in your C code you're only returning the last (and hence the first, lexically speaking) digit to be printed.
  23. I'd say another consideration might be: just how...

    I'd say another consideration might be: just how large are these lists of tokens in production, and how long does each token tend to be? If these lists are long enough and comparing tokens expensive...
  24. You should provide private member functions. Why...

    You should provide private member functions. Why don't you like them? They are better than friend functions because, like non-private member functions, friend functions extend the interface of the...
  25. Three options come to mind: Copy the...

    Three options come to mind:

    Copy the subsequent elements to overwrite the deleted element, reducing the recorded size by 1. This maintains the relative order, but unfortunately deletions then run...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4