Search:

Type: Posts; User: hamster_nz

Page 1 of 6 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    129

    Do you need something like this? ...

    Do you need something like this?



    printf("Enter your birth year\n");
    scanf("%d", &year);
    while(year<=1920 || year>=2020) {
    printf("Invalid Year of Birth \n");
    printf("Re-enter your...
  2. Oh, you also need to have a non-blocking open on...

    Oh, you also need to have a non-blocking open on the pipe:



    int fd = open("mySemaphorPipe", O_RDWR|O_NONBLOCK);


    From "man 7 fifo"
  3. Hey! Found it.... For sem_open, you need...

    Hey! Found it....

    For sem_open, you need O_CREAT, not IPC_CREAT.

    Also, your name (SEM_WRITE) MUST begin with a leading slash.

    And the semaphore needs an initial value of 1.

    And you should...
  4. Replies
    3
    Views
    129

    Can you show us your sample output when the...

    Can you show us your sample output when the problem occurs?

    I suspect you want to 'loop' around when getting the date, while the day, month or year is invalid.

    Also this might be an easier way...
  5. How many processes do you want? Because you 7...

    How many processes do you want? Because you 7 running, I think.
  6. Interesting. Are you running it on ARM? ...

    Interesting. Are you running it on ARM?

    Because on Intel you have a security issue as characters are signed, so:



    hasChar[ string[i] ] = 1


    ...will trash the stack. This could...
  7. Replies
    6
    Views
    263

    Three options I can see straight off: 1....

    Three options I can see straight off:

    1. Memory is cheap. Why not just set an upper teams of 1000 teams, and 100 character long names. Thats < 0.1 megabyte.

    2. Put them into a linked list,...
  8. Replies
    3
    Views
    171

    One of your == is an =. Maybe turn on all the...

    One of your == is an =.

    Maybe turn on all the compiler warnings?
  9. You are playing with fire here... it will burn...

    You are playing with fire here... it will burn you!

    Here... have a match and some lighter fluid:



    ProductType *p;
    p = (ProductType *)product.
  10. Also b->grid[i][j] =...

    Also



    b->grid[i][j] = toupper(b->grid[i][j]);


    Is most likely a little bit suspect. You will be updating the contents of the grid and that might have a wider impact in a larger program.
  11. I'm guessing it is because "category" is in...

    I'm guessing it is because "category" is in 'EntityType', and not in 'ProductType'.
  12. Thread: Recursion

    by hamster_nz
    Replies
    1
    Views
    137

    You might notice that even and odd are much the...

    You might notice that even and odd are much the same function...

    odd(n);

    will be the same value as:

    even(n/10);

    Also, something about the "if(n < 10)" feels wrong. I feel you should be...
  13. Replies
    17
    Views
    362

    Using size_t is the right thing to do, but feel...

    Using size_t is the right thing to do, but feel free to use plain old int.

    'size_t' is just an appropriately sized unsigned integer that matches the processor's address space.
  14. Replies
    9
    Views
    281

    Can you reword that so you are clear about...

    Can you reword that so you are clear about 'bytes', characters, C 'chars' and unicode characters?

    They are all slightly different things.

    Using mixed somewhat vague words is obscuring the...
  15. Replies
    9
    Views
    281

    Wikipedia has a graphic with all the info you...

    Wikipedia has a graphic with all the info you need at UTF-8 - Wikipedia - UFT-8 can be up to 8 bytes in length, but they don't have to be.

    Also, think about using getc() rather than read(). It...
  16. Replies
    17
    Views
    362

    I would approach it this way. // Returns...

    I would approach it this way.



    // Returns 0 if all the same or empty.
    // 1 if increasing
    // 2 if decreasing
    // 3 if unsorted
    int order(unsigned array[],...
  17. Replies
    17
    Views
    362

    If rmmstn is still reading the thread, you have a...

    If rmmstn is still reading the thread, you have a problem here:



    for(int i = 0; i < n; ++i){


    For n items, you need to make n-1 comparisons.
  18. Replies
    17
    Views
    362

    Safe to assume it is the build-up to writing a...

    Safe to assume it is the build-up to writing a sort function.

    Write the test first....
  19. You might find this interesting. It uses "ANSI...

    You might find this interesting.

    It uses "ANSI Escape Sequences" to plot things on the console - or at least it does under Linux. I haven't tested it in a Windows Console.



    #include...
  20. 2D or 3D? What do you need your output as? ...

    2D or 3D? What do you need your output as?

    Here's the pseudocode for your program.



    main function()
    read in initial state (positions, masses, velocities) from a file
    ...
  21. With only the include file path is scanned....

    With <> only the include file path is scanned.
    With "" the current directory is first scanned, then the include file path is scanned.

    I would keep the private file in with your source, and the...
  22. Replies
    6
    Views
    266

    (byte)(0xFF - 0x30U) = ? (byte)(0xFF - 0x30U)...

    (byte)(0xFF - 0x30U) = ?

    (byte)(0xFF - 0x30U) = 0xCF.

    If that is a + or - number depends on the definition of 'byte'.
  23. I am not sure what you mean by this. Are you...

    I am not sure what you mean by this. Are you looking at it in an IDE?

    But to answer your question, I would would not have either header file include the other, but include both in the source .c...
  24. Replies
    6
    Views
    266

    You can't have that code. THere are unbalanced...

    You can't have that code. THere are unbalanced brackets in the 'it' statements.

    And " mac1 = 0x10" is missing the semicolon.

    I've made a compellable program:



    #include <stdio.h>...
  25. Replies
    6
    Views
    266

    I haven't looked at your code deeply, what...

    I haven't looked at your code deeply, what platform are you on?

    On Intel, 'char' is a signed type, so 0xFF is -1.

    On ARM 'char' is unsigned, so 0xFF is 255.

    If you have all the compiler...
Results 1 to 25 of 135
Page 1 of 6 1 2 3 4