Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • Pointer indirection

    question
    12
    0 Votes
    12 Posts
    48 Views
    L
    You're welcome. It always helps to look at actual code.
  • Tile childwindow

    3
    0 Votes
    3 Posts
    23 Views
    C
    After so many years your hint to send the message to the client area (not the frame) was very helpful for me. Thanks!
  • [edited] collision response in a RTS

    question
    9
    0 Votes
    9 Posts
    38 Views
    L
    You're welcome! "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
  • DSA

    data-structures
    13
    0 Votes
    13 Posts
    51 Views
    CPalliniC
    Quote: How is that possible sir! Second code is written by a renowned youtuber 'code_with_harry'. I know. But here is renowed expert CPallini :-D. If you run Harry's code using Valgrind, then you get (something similar to) ==3144== LEAK SUMMARY: ==3144== definitely lost: 64 bytes in 4 blocks ==3144== indirectly lost: 0 bytes in 0 blocks ==3144== possibly lost: 0 bytes in 0 blocks ==3144== still reachable: 0 bytes in 0 blocks ==3144== suppressed: 0 bytes in 0 blocks ==3144== ==3144== For lists of detected and suppressed errors, rerun with: -s ==3144== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) On the other hand, if you run the following, alternative code #include #include struct Node { int val; struct Node * next; }; void traversal(const struct Node * p) { printf("------------\n"); while (p) { printf("%d ",p->val); p = p->next; } printf("\n------------\n"); } // isEmpty is not strictly needed // isFull is meaning-less struct Node * enqueue(struct Node *p, int val) { struct Node * prev = NULL; while (p) { prev = p; p = p->next; } p = malloc(sizeof(struct Node )); if ( p ) { p->val = val; p->next = NULL; if ( prev ) prev->next = p; } return p; } int dequeue(struct Node ** pp) { int val = -1; struct Node * p = *pp; if ( p ) { val = p->val; *pp = p->next; free(p); } return val; } int main() { struct Node * ph = enqueue(NULL, 11); enqueue(ph, 22); enqueue(ph, 33); enqueue(ph, 44); traversal(ph); dequeue(&ph); dequeue(&ph); traversal(ph); dequeue(&ph); dequeue(&ph); return 0; } then Valgrind is somewhat happier: ==3153== HEAP SUMMARY: ==3153== in use at exit: 0 bytes in 0 blocks ==3153== total heap usage: 5 allocs, 5 frees, 1,088 bytes allocated ==3153== ==3153== All heap blocks were freed -- no leaks are possible ==3153== ==3153== For lists of detected and suppressed errors, rerun with: -s ==3153== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) "In testa che avete, Signor di Ceprano?" -- Rigoletto
  • Invalid application of 'sizeof' to incomplete type 'struct Node'

    help question
    8
    0 Votes
    8 Posts
    35 Views
    CPalliniC
    You are welcome. "In testa che avete, Signor di Ceprano?" -- Rigoletto
  • Get LVN_MARQUEEBEGIN in CListCtrl

    question
    12
    0 Votes
    12 Posts
    40 Views
    L
    Good job, happy to see you solved it.
  • conversions in 64 bit mode

    csharp c++ visual-studio question
    5
    0 Votes
    5 Posts
    21 Views
    L
    The question is, why would you want to do such a thing? The LRESULT type has a specific meaning and purpose, which is not the same as an int, or any other basic, type.
  • generate PDF file

    c++ question
    3
    0 Votes
    3 Posts
    4 Views
    J
    When I googled certainly seem to suggest that. "C++" pdf libary Not free (I don't think) but years ago Crystal Reports had an API and among many outputs possible was PDF.
  • STOP CListCtrl selection rectangle

    question
    9
    0 Votes
    9 Posts
    5 Views
    L
    I have a class, named MyListCtrl which is inherited from CListCtrl. Why I didn't get LVN_MARQUEEBEGIN notification in MyListCtrl::OnNotify() when clicking and dragging??? :( :( :(
  • Update a value inside a class using a function

    help c++ question announcement
    9
    0 Votes
    9 Posts
    5 Views
    K
    As you're using C++, you might consider using a std::map for the internal data structure. e.g std::map. If you do that, then you can access an account via its account number, without searching for it std::map accounts; accounts[account_no].dep(amount); // add amount to an account; Keep Calm and Carry On
  • Writing console c++ apps... console API or library?

    c++ json question
    6
    0 Votes
    6 Posts
    5 Views
    J
    Long ago I just did it myself. The libraries that get fancy tended to rely on stuff that I couldn't be sure existed or at least would existed in the future. Not to mention that a console app should be pretty simple in the first place. If you need complex user interactions then a console app probably isn't the way. If I didn't want a normal UI then I would be more likely to control it via either command line options and/or configuration files. Actually I have been doing just those for years without any need for anything else.
  • how i convert my x86 project in x64

    help workspace
    4
    0 Votes
    4 Posts
    5 Views
    B
    on toolbar, change debug and release setting to win64
  • postmessage

    c++ visual-studio design question
    5
    0 Votes
    5 Posts
    2 Views
    V
    You probably would like to read this great Joe Newcomer's essay about using [WorkerThreads](http://www.flounder.com/workerthreads.htm)
  • Gelatinous 0588659218 Dubai Call Girl Numbers Downtown Call girls Dubai

    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Jadwal Slot Online Gacor Terbaik Banyak Jackpot PG Soft

    com sales question
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • parsing time (only) string with std::chrono

    c++ com devops json tutorial
    5
    0 Votes
    5 Posts
    8 Views
    M
    thanks. CI/CD = Continuous Impediment/Continuous Despair
  • VS6 (C++), Group Bar - icon instead of text - how to?

    c++ wpf help tutorial question
    5
    0 Votes
    5 Posts
    15 Views
    Mircea NeacsuM
    Excuse me for asking, but why would you still be using VS6? Seems to be a 20+ years old product and there have been innumerable versions after that. I seems to remember having used it long time ago but any memory has been lost in the darkness of time. I'm sure you must have a good reason and I'm asking only out of curiosity. Please don't misinterpret it as a critique or something. Mircea
  • 0 Votes
    11 Posts
    4 Views
    L
    I'm more interested in helping people than pleasing them. Probably one of the reasons I got in trouble at work.
  • RTS game overview chart

    game-dev algorithms help question
    5
    0 Votes
    5 Posts
    3 Views
    A
    This is very broad, you need to break this down into way smaller chunks, design modules for each part i.e. building and line of sight, pathways and obstacles etc. etc. Maybe follow the following link on where to start - WHERE TO START IN GAME DEVELOPMENT[^] Quote: Many developers love games and want to build games. But game development is a vast ocean. There are so many aspects to developing a game that it's hard to understand where a game developer should even start. One way to start building a game is by choosing how you will build it. Regardless of whether you're an indie developer or an established game development studio, there are 3 ways you can build a game.
  • C++ compiler that supports multiple inheritance

    c++ delphi visual-studio oop question
    4
    0 Votes
    4 Posts
    2 Views
    U
    I mean in same way as Turbo C++ did. For C# and all are basically java. They don't do multiple inheritance as effortlessly as Turbo C++ use to.