Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.12 seconds.

  1. Replies
    12
    Views
    130

    You get 1 from that division, not 0. Assuming...

    You get 1 from that division, not 0. Assuming non-negative input, the issue is specifically for n == 0 because the loop condition is never satisfied, hence c remains 0.


    That's what I would...
  2. Replies
    12
    Views
    130

    Not quite: len(0) is incorrect, and if you don't...

    Not quite: len(0) is incorrect, and if you don't intend to handle negative numbers, you should deal with unsigned int rather than int.


    How does it not work? Just saying that you still have a...
  3. Replies
    12
    Views
    130

    I'd suggest using a while loop instead of a for...

    I'd suggest using a while loop instead of a for loop and comparing with 0 in the loop condition.
  4. Replies
    12
    Views
    130

    Ah, how interesting. I compiled and ran this...

    Ah, how interesting. I compiled and ran this program:

    #include <stdio.h>

    int len(int n) {
    int i, count = 1;
    for (i = 0; i <= n; i++) {
    count++;

    n /= 10;
  5. CLion is an IDE, not a compiler. My guess is that...

    CLion is an IDE, not a compiler. My guess is that you're using the MinGW port of gcc, and if so, this appears relevant: Implicit declaration of timersub() function in Linux - what must I define?
    ...
  6. No, not in : struct timeval and...

    No, not in <time.h>: struct timeval and consequently timersub are not part of the C standard. From what I see it should be declared in <sys/time.h>, which you did include. So that's a little...
  7. Replies
    12
    Views
    130

    That's a little confusing to me: what's the...

    That's a little confusing to me: what's the difference between "largest digit length" and "largest number of digits"? I'm guessing that you meant:

    Compute the sum of digits of each number and...
  8. Replies
    19
    Views
    327

    That looks like a bug in the documentation :o

    That looks like a bug in the documentation :o
  9. Replies
    19
    Views
    327

    I wrote "where the type of numBytes is the return...

    I wrote "where the type of numBytes is the return type of Udp.read". This has absolutely nothing to do with the type of packetBuffer, which is in fact char[256], not char. The return type of Udp.read...
  10. Replies
    19
    Views
    327

    That makes it easy. I'd suggest something like...

    That makes it easy. I'd suggest something like this:

    numBytes = Udp.read(packetBuffer, 255);
    if (numBytes != 3) {
    // handle unexpected input error
    // ...
    }

    unsigned int result = 100...
  11. Replies
    19
    Views
    327

    Are you sure you are getting a compile error? It...

    Are you sure you are getting a compile error? It is legal to implicitly convert a char to an unsigned char, and even if char is signed that conversion is well defined so I would not expect even a...
  12. Formatting your code properly and posting it...

    Formatting your code properly and posting it within forum bbcode code tags as Zeus_ suggested is really important. It looks like your code attracted the attention of the forum software that does...
  13. Replies
    10
    Views
    255

    Yes, this revised code looks semantically...

    Yes, this revised code looks semantically equivalent to the code in post #1.

    Of course, this means that you can move on to other things, but if you think you've found a compiler bug and want to...
  14. Replies
    10
    Views
    255

    You mean without conditional operators? The code...

    You mean without conditional operators? The code from post #1 that you said didn't compile on clang is the one that uses a conditional operator.

    As john.c mentioned in post #5, your code in post...
  15. Replies
    2
    Views
    125

    You used || instead of | I'm a bit puzzled why...

    You used || instead of |

    I'm a bit puzzled why you would use bitwise or though: wouldn't that mean that differing msb and lsb parts can result in the same device id?

    EDIT: oh, I misread the...
  16. Replies
    6
    Views
    279

    The behaviour is undefined because you attempt to...

    The behaviour is undefined because you attempt to modify the same object more than once between consecutive sequence points (or you read it and also modify it separately). So, the reason why you get...
  17. Replies
    2
    Views
    148

    You're reading an entire line, then you're...

    You're reading an entire line, then you're reading more input to ignore it, before you print the next prompt.

    So when the user enters their name, you're still waiting for them to enter something...
  18. Replies
    3
    Views
    199

    I use clang's C++ compiler on macOS Catalina at...

    I use clang's C++ compiler on macOS Catalina at the command line, although out of habit I invoke it as g++. I did not install Xcode, and in fact I use VS Code to edit C++ code.
  19. Replies
    6
    Views
    378

    Firstly, you should be aware that this: double...

    Firstly, you should be aware that this:

    double convert(double abw_to_abv[9], double abw);
    is equivalent to:

    double convert(double abw_to_abv[], double abw);
    which is equivalent to:

    double...
  20. Replies
    12
    Views
    324

    Well, if you want further help, I'd suggest that...

    Well, if you want further help, I'd suggest that you start my answering my questions from my previous post:
  21. Have you seen this issue elsewhere in the...

    Have you seen this issue elsewhere in the meantime?

    I'm afraid that while moderators have been given some magic, the deep magic required to correct the fabric of this universe belongs to the...
  22. Replies
    2
    Views
    158

    In your original code, I would change this: ...

    In your original code, I would change this:

    while(scanf("%d", &num) != EOF)
    to this:

    while(scanf("%d", &num) == 1 && num != -1)
    That is, you keep looping as long as you read and assign 1...
  23. Replies
    12
    Views
    324

    It already is a float. What you want to do is...

    It already is a float. What you want to do is print a textual representation of the float.


    What's the point? ftoa is a non-standard function, whereas you have the family of printf/sprintf...
  24. Replies
    12
    Views
    324

    How does it not work? Your own post #1 implies...

    How does it not work? Your own post #1 implies that it works, just that you want to do something else.
  25. That's because you're using dataIn as an...

    That's because you're using dataIn as an input/output parameter. I was trying to get you to redesign your program to use it as an input parameter, then provide the output by another way.


    That's...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4