Search:

Type: Posts; User: pankaj401

Search: Search took 0.01 seconds.

  1. Replies
    7
    Views
    5,413

    All the variables involved are float. I,...

    All the variables involved are float.

    I, finally, used the epsilon check.
  2. Replies
    7
    Views
    5,413

    Floating point - check for divide-by-zero

    I need to know how could I check for a floating point number being "equal to" or "close enough" to 0.0f.
    I have this:


    buttonWidth = buttonRect.right - buttonRect.left;
    buttonHeight =...
  3. Thread: Macro

    by pankaj401
    Replies
    5
    Views
    2,034

    Shouldn't it be? #define SETMSB(x) (x) |= 1

    Shouldn't it be?
    #define SETMSB(x) (x) |= 1 << ((sizeof(x) * CHAR_BITS) - 1))

    My guess is that all this would only work for datatypes that can fit into processor registers.
  4. Thread: Macro

    by pankaj401
    Replies
    5
    Views
    2,034

    if you consider a 32 bit int you can use ...

    if you consider a 32 bit int you can use


    int i = 0;
    i = ( i | ( 1 << 32 ) ); // Set MSB
  5. Replies
    6
    Views
    2,170

    int a = 9, b = 10; int *c; c = &a;...

    int a = 9, b = 10;
    int *c;
    c = &a;

    The variables a, b and c would be stored on stack.
    And the values 9 and 10 would be saved along with the code ( in text segment ).
  6. sizeof() is an operator and not a function.

    sizeof() is an operator and not a function.
  7. My mistake: Should have been char...

    My mistake: Should have been
    char days[7][10]={ "Sunday", "Monday",... "Saturday" }; // You could keep this global in .text or .rodata
  8. Replies
    3
    Views
    1,095

    You are reading ch without initializing. This...

    You are reading ch without initializing. This could also be one of the reasons for your code not working.
  9. Replies
    5
    Views
    5,397

    I would suggest that you reverse the string in...

    I would suggest that you reverse the string in place and then print it with "&#37;s" format specifier. That way you save multiple calls to printf.
  10. Array would be passed as the address of location...

    Array would be passed as the address of location where the array starts. As long as you have a stack it wouldn't be anymore expensive than a funtion call and a parameter push.
  11. How about indexing the character array conatining...

    How about indexing the character array conatining day strings with the values [1...7] returned in the byte.


    char days[7][]={ "Sunday", "Monday",... "Saturday" }; // You could keep this global in...
  12. What exactly are you trying to do here? ...

    What exactly are you trying to do here?


    while(fgets(str,300,infp)!=NULL)
    {
    puts(str);
    }

    This would keep reading the input stream and putting the same to the output stream until an error...
  13. Replies
    19
    Views
    3,451

    You can use a MASK to hide all other bits except...

    You can use a MASK to hide all other bits except LSB and print 1or 0 depending on what the character & MASK evaluates to. You can do this for all bits in the character.
  14. Replies
    10
    Views
    1,387

    #define GETFOO (Foo( &counter ), counter)...

    #define GETFOO (Foo( &counter ), counter)
    What's with the , [comma ]operator here?
  15. Replies
    26
    Views
    4,926

    Yes programmers can generally do that.

    Yes programmers can generally do that.
  16. Replies
    13
    Views
    3,143

    if (askedForName == 0) /* Name asked for...

    if (askedForName == 0) /* Name asked for only once */
    { printf("\nWhat is your first name? ");
    Missing closing brace for this if in function initCardsScreen.


    points[ACEHIGH += 10;....
  17. Thread: tcp/ip chat

    by pankaj401
    Replies
    12
    Views
    3,722

    Once created the OS should schedule the thread...

    Once created the OS should schedule the thread automatically unless they are blocked/suspended.
    Which OS are you using?
  18. Seems like one of those things which does not...

    Seems like one of those things which does not make sense in real world but good for interview stuff ;)
  19. Replies
    4
    Views
    996

    You should set the my_pointer to NULL so that you...

    You should set the my_pointer to NULL so that you do not have any dangling references anymore once you free().
  20. Discussing with colleagues over some beer I...

    Discussing with colleagues over some beer I actually ended up finding that we can delete the isolated node except if it is the last node in the list.
    All you need to do is copy the current->next and...
  21. I think he means that only a lone [address of a]...

    I think he means that only a lone [address of a] node is given. Provided it's a singly linked list and the head is not known deleting that node while keeping rest of the list intact wouldn't be...
  22. Replies
    7
    Views
    1,010

    You can extract the digits, starting at 1's, then...

    You can extract the digits, starting at 1's, then 10's, then 100's place and so on, from the given integer and keep track of number of 2 encountered.
  23. Replies
    1
    Views
    930

    Read this:...

    Read this:
    http://cboard.cprogramming.com/showthread.php?s=&threadid=26294, and
    http://cboard.cprogramming.com/announcement.php?f=4&a=39
  24. Replies
    5
    Views
    1,291

    int operator; /* begin while loop */ while(...

    int operator;

    /* begin while loop */
    while( operator != 11 ) /* program continues until input of 9 */

    You also need to initialize operator before using it.
Results 1 to 24 of 24