Search:

Type: Posts; User: legend

Search: Search took 0.01 seconds.

  1. Replies
    14
    Views
    1,869

    you only need to call CreateCompatibleDC() once...

    you only need to call CreateCompatibleDC() once for each memory device context since GetDC() returns the same value for a given HWND. as far as saving and restoring the value of SelectObject(), it...
  2. Replies
    6
    Views
    1,104

    if your program is called with command line...

    if your program is called with command line arguments chances are the 'current directory' isn't the program directory. if so, you can extract the application's path from the first command line arg...
  3. Replies
    5
    Views
    2,024

    the way I always do it is: - using tmpnam(),...

    the way I always do it is:

    - using tmpnam(), create a temp file
    - write new data to temp file
    - rename original file using tmpnam()
    - rename temp file to original name
    - delete the old file
    ...
  4. Replies
    2
    Views
    819

    you need to add the 'typename' qualifier when...

    you need to add the 'typename' qualifier when referencing a typedef external to a template.



    typename vector<Type>::iterator begin() {
    return _data.begin();
    }


    an easier way is to...
  5. Replies
    7
    Views
    2,569

    the hash table can be any abitrary size (but the...

    the hash table can be any abitrary size (but the larger the table, the less chances for collisions to occur - if the table is too small you the won't get much performance out of it), so you calculate...
  6. Thread: Template

    by legend
    Replies
    13
    Views
    1,311

    another approach is to provide a typedef within...

    another approach is to provide a typedef within the template for any internal type you may want to make accessible to other templates:



    template <class DataType>
    struct TestStruct {
    typedef...
  7. Replies
    15
    Views
    2,443

    well, you just have to be sure to do something...

    well, you just have to be sure to do something with the data between calls.
  8. Replies
    15
    Views
    2,443

    definately not a good idea. just add an extra...

    definately not a good idea. just add an extra parameter to the function for a destination buffer.
  9. Replies
    6
    Views
    3,923

    you pass 'domains' by value so the changes you...

    you pass 'domains' by value so the changes you make are performed on a copy of it. change the parameter to a char *** and you will have the variable itself - just dereference the pointer in the...
  10. Replies
    16
    Views
    3,612

    me too! bool isPalindrome(const char *...

    me too!



    bool isPalindrome(const char * data)
    {
    for(const char * tail = data + strlen(data) - 1; data < tail; tail--, data++)
    {
    while(isspace(*data) || ispunct(*data)) data++;
    ...
  11. Thread: Bit Computation

    by legend
    Replies
    18
    Views
    2,699

    bit shifting wouldn't be very useful if he plans...

    bit shifting wouldn't be very useful if he plans to use character arrays. It would be more logical to use binary data in the first place of course.
  12. Replies
    3
    Views
    897

    if ( board[1] == board[4] == board[7] ){ ...

    if ( board[1] == board[4] == board[7] ){


    that expression evaluates "board[1] == board[4]" first, then takes the boolean result
    (1 or 0) and compares it to the cell at board[7]. you need to...
  13. Replies
    9
    Views
    1,762

    you can use the function 'clock' in a loop to...

    you can use the function 'clock' in a loop to create a pause effect like that.
  14. Replies
    4
    Views
    1,178

    check out www.boost.org

    check out www.boost.org
  15. Replies
    9
    Views
    1,493

    I was basing my advice on this from MSDN: ...

    I was basing my advice on this from MSDN:

    "MSG_PEEK: Peeks at the incoming data. The data is copied into the buffer, but is not removed from the input queue. The function subsequently returns the...
  16. Replies
    5
    Views
    1,152

    the encoding used may not yield the correct value...

    the encoding used may not yield the correct value using that method. for instance, using gray's code there's a single bit of difference between neighboring values - so subtracting values would...
  17. Replies
    5
    Views
    1,152

    int ctoi(char ch) { char temp[2] = {ch, 0}; ...

    int ctoi(char ch) {
    char temp[2] = {ch, 0};
    return atoi(temp);
    }


    you could use simple arithemetic on the character values too, but I'm not sure how portable that would be.
  18. Replies
    18
    Views
    6,154

    you could pass the hash generator as a template...

    you could pass the hash generator as a template parameter (that would default to some predefined object).
  19. Replies
    9
    Views
    1,493

    you can (I think) query the recieve buffer with...

    you can (I think) query the recieve buffer with something like this:

    needed = recv(W, &Char, 0, MSG_PEEK);
  20. Replies
    6
    Views
    1,016

    void addItem(IntList *data, int newItem, unsigned...

    void addItem(IntList *data, int newItem, unsigned location)
    {
    unsigned i;
    for (i=data->size;i>location;i--)
    data->number[i] = data->number[i-1];

    ...
  21. Replies
    6
    Views
    1,016

    take a wild guess.

    take a wild guess.
  22. Replies
    6
    Views
    1,016

    you're not incrementing the structure's 'size'...

    you're not incrementing the structure's 'size' variable each time you add an item.
  23. Thread: String Problem

    by legend
    Replies
    9
    Views
    1,331

    why not use strtok?

    why not use strtok?
  24. Replies
    8
    Views
    1,559

    you can also write a custom char_traits object...

    you can also write a custom char_traits object and pass it as the second template parameter of basic_string to override the default comparison semantics.
Results 1 to 24 of 24