Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds; generated 18 minute(s) ago.

  1. Why do you think that "C thinks stuff inside a...

    Why do you think that "C thinks stuff inside a function is global?"
    I don't get that impression at all.


    No it doesn't.

    As for the difference between a 2d array and a double pointer,...
  2. main returns an int. Nothing is gained by making...

    main returns an int. Nothing is gained by making it void.
    You have no prototype for phm.
    test1 is not an int**. It is an int[][10].
    I have no idea what you think stuff like the following means so...
  3. I suppose you would need a mutex since otherwise...

    I suppose you would need a mutex since otherwise main could be printing the values when one but not the other has been changed by the second thread, or perhaps one could have been half changed.

    I...
  4. Replies
    12
    Views
    1,316

    As I said before, I was able to find the...

    As I said before, I was able to find the following solution, which is in fact the only solution. Below I added the wheel number as per the original picture so that you can check that these are the...
  5. Replies
    4
    Views
    665

    Apparently you can also write the typedef like...

    Apparently you can also write the typedef like this, without the parentheses and asterisk:


    typedef int FUNC(int, int);

    You can also leave the parentheses and asterisk out of the using alias:...
  6. Replies
    4
    Views
    665

    It's the typedef of a function pointer. Consider...

    It's the typedef of a function pointer.
    Consider


    typedef int (*FUNC)(int, int);

    This is a typedef for a function that takes two ints and returns an int. The type is called FUNC.
    E.g., this...
  7. Replies
    12
    Views
    1,316

    It would be much more work to write detailed...

    It would be much more work to write detailed pseudocode than to post the program. But basically it is:


    For each permutation of the wheel positions:
    For each orientation of the wheels in...
  8. Replies
    11
    Views
    952

    @Dadu, My example was not meant as a full...

    @Dadu, My example was not meant as a full solution.
    It was just meant to show you that the nested while loops were incorrect.
  9. Replies
    12
    Views
    1,316

    I'm not posting the answer, at least not anytime...

    I'm not posting the answer, at least not anytime soon.

    Yes, you will need nested loops, although it's a little more complicated than that.

    You need to generate the permutations of the wheel...
  10. Replies
    12
    Views
    1,316

    If the wheel color data is stored like this: ...

    If the wheel color data is stored like this:


    #define NUM_WHEELS 7
    #define NUM_COLORS 6

    enum {Black, Red, White, Blue, Yellow, Green};

    int wheels[NUM_WHEELS][NUM_COLORS] = {
    {...
  11. There are no lines. Try making download_buf...

    There are no lines.

    Try making download_buf and upload_buf bigger. calculateSize definitely has the potential to write more than 8 bytes to them, e.g., 123.7 KiB will write 10 bytes. There's no...
  12. Replies
    12
    Views
    1,316

    The difficulty here is how to represent the...

    The difficulty here is how to represent the problem in the program.
  13. The second is usually better since there's not...

    The second is usually better since there's not much point for malloc to create something of a fixed size.
    No, of course buffer does not need to be freed in the second example.
    You already have...
  14. Replies
    11
    Views
    952

    Why can't it just be something like this. ...

    Why can't it just be something like this.


    L1--------L2--------L3 Lasers
    | | |
    | | |
    | | |
    | | |
    | | |...
  15. Replies
    11
    Views
    952

    I don't understand how we know there are three...

    I don't understand how we know there are three sensors from the picture.
    What are the little white squares and red dotted lines on the ground?

    16464

    And if there's three sensors, why does...
  16. Your "err" routine is pointless. And you need to...

    Your "err" routine is pointless.
    And you need to check argc before accessing argv[1].
    \e is a non-standard escape sequence. Better to use \033 or \x1b.


    #define _POSIX_C_SOURCE 200809L...
  17. Replies
    12
    Views
    2,337

    You can of course often beat the standard...

    You can of course often beat the standard allocator in particular cases where you know the pattern of allocation/deallocation. In such a case you can build something on top of the standard allocator...
  18. No it doesn't. It never has to "iterate the...

    No it doesn't. It never has to "iterate the stack" for anything, ever. Why do you think it does that?
  19. I don't understand what you mean by "iterate...

    I don't understand what you mean by "iterate through the stack to find pointers", but obviously your "optimized" function will be slower since it's doing more work. The "original" function simply...
  20. Replies
    3
    Views
    320

    Why do you think it's dereferencing (not...

    Why do you think it's dereferencing (not deference!) a null pointer?
    The else on line 34 pairs with the if on line 17, not the if on line 13.
  21. Replies
    3
    Views
    368

    I would say the second is better since then the...

    I would say the second is better since then the user can choose to create the object on the stack or the heap.
    It should have a return type of int or possibly bool to indicate success/failure....
  22. Replies
    9
    Views
    818

    Once you've installed it, you should refer to the...

    Once you've installed it, you should refer to the header files in your source code like this:


    #include <soem/osal.h>
    #include <soem/oshw.h>

    Then compile like this:


    gcc yourprog.c -o...
  23. Replies
    9
    Views
    818

    Did you execute sudo make install from the...

    Did you execute sudo make install from the build directory?
    If not, do so.
  24. Replies
    9
    Views
    818

    You could pass -I/home/raspberrypi/SOEM and then...

    You could pass -I/home/raspberrypi/SOEM and then specify header files like:


    #include "osal/whatever"
    #include "oshw/whatever"
  25. Replies
    9
    Views
    818

    You need to tell gcc where the include files are...

    You need to tell gcc where the include files are with the -I flag:
    -I/path/to/include/files
    You need to tell gcc where the library files (.a or .so files) are with the -L flag:...
Results 1 to 25 of 496
Page 1 of 20 1 2 3 4