Strange problem with sprintf()

Im writing a function to display binary tree in nice format, but something got wrong with the sprint() function. If I just comment out that sprint() line, the program will work fine. So what im missing right there?
Please help me correct this.

1
2
3
4
    printf("%p\n", tree->leftChild); //Run fine
    sprintf(buffer, "%*d%*s", wide/level, tree->key, wide/level, "");
    printf("%p\n", tree->leftChild); //Crash, using Qt Debugger show me some
                                    //kind of "inaccessible" to tree->leftChild 


EDIT: after sprint(), any code using tree->leftChildmade the program crashed
Last edited on
it's rather likely that you have a buffer overrun on line 2. This '*' approach makes it rather likely
Topic archived. No new replies allowed.