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
  • 0 Votes
    4 Posts
    19 Views
    C
    Richard and Mircea thanks for advice
  • Embedded and dynamic memory allocation

    design hardware com graphics iot
    17
    0 Votes
    17 Posts
    77 Views
    L
    Embedded includes very large systems and processors these days and dynamic allocation has become very common on those. Even with an RTOS on a smaller micro they will typically use dynamic allocation and support most options FreeRTOS is typical and as you see there are 5 options on it FreeRTOS - Memory management options for the FreeRTOS small footprint, professional grade, real time kernel (scheduler)[^] Perhaps to give a more informed answer we need need to know what your intended system is. In vino veritas
  • help me to understand my regular expression error AND solve it

    regex help
    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • Invalidate rectangle

    graphics json question
    10
    0 Votes
    10 Posts
    60 Views
    C
    I might do some searching through CP. There are some excellent articles covering the madness of Windows drawing, GDI, etc. DCs, their variations and purposes are also covered pretty well. Just keep in mind the point behind InvalidateRectangle - GDI is somewhat smart. It will limit it's drawing to regions it knows it needs to re-draw which is why you need an InvalidateRectangle call. Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.
  • Myth of a Myth?

    c++ com debugging performance help
    4
    0 Votes
    4 Posts
    21 Views
    L
    It was a silly article, going out of his way to create a bug and then blaming it on the thing he just intentionally broke. But doing things with C++ that rely on platform/compiler specific details is explicitly allowed, and frequently necessary. The C++ specification alone does not make enough guarantees to result in a useful system - intentionally, so that the details can differ.
  • download a web page

    help com sysadmin tutorial question
    6
    0 Votes
    6 Posts
    17 Views
    Mircea NeacsuM
    Glad to hear it! Now, if you want to check a more C++ way of working with sockets, you can take a look at my series of articles about working with Windows sockets in C++. First instalment is Windows Sockets Streams[^]. Latest version of code can be downloaded from GitHub[^]. Mircea
  • printf without stdio.h

    csharp visual-studio question
    7
    0 Votes
    7 Posts
    37 Views
    J
    k5054 wrote: Its good practice to #include all the relevant headers I agree. This specific case is rather simplistic but in larger applications with company code all over the place relying on chains is just a maintenance (preventable) problem waiting to happen.
  • copying a file in C++17

    c++ help question
    3
    0 Votes
    3 Posts
    6 Views
    J
    mike7411 wrote: Is this a good way of doing it? 1. You want to check what happens if different drives are involved. 2. You want to verify paths are supported. 3. Catching one type of exception ignores possible other ones. Probably unlikely but in case. mike7411 wrote: buffer sizes are being used behind the scenes? There are all sorts of possible buffers. Disk, OS, library. Only concern however for that is speed. You can profile it. You can also use a OS command shell call for comparison. If it matters, at least in my experience, OS shell commands will always be faster. This is especially true when copying directories. Seems reasonable given that the copy operation in the OS doesn't involve loading the data into the application. Even so if you need it to be 'fast' for some reason then I would suggest that you need to change your requirements/design. Copying files, in general, is always 'slow'. Speed doesn't matter for single small files. So only matters for very large files and/or large numbers of files. But those will always be 'slow'. And there can be error conditions that make it even slower (which your code does not account for.) So attempting to guarantee a speed rate is never going to work.
  • copying a file

    question
    4
    0 Votes
    4 Posts
    11 Views
    K
    While your method may work, assuming that ch is an int, and so does not have the 255/-1 issue, your method is horribly inefficient. Richard's suggestion to use fread/fwrite produces much better performance. For example, given an 8M file, looping through your code 100 times took about 32 seconds. Using a fread/fwrite using a 4K buffer, the same 100 lops took just under 1 second to complete. This was on a PI-3, and successive runs remained stable. I'd expect an 8M file to sit comfortably in the file cache, so the difference is totally down to the difference between extracting a single char at a time, and reading a lot of characters at a time. "A little song, a little dance, a little seltzer down your pants" Chuckles the clown
  • how to add another primary menu - C + in Qt

    tutorial
    3
    0 Votes
    3 Posts
    12 Views
    L
    A number of previous incarnations, one of which was at Discussions - Linux Programming Discussion Boards[^]
  • another "include" question...

    help question tutorial
    11
    0 Votes
    11 Posts
    33 Views
    L
    The project does not "use the include files". They are putely source code definitions and declarations used by the compiler to build the object file. What hapens in reality is the the compiler reads every file that is (directly or indirectly) named in an #include statement, and builds a new source file that comprises your source code plus all the included text. It then processes that source to create the object file. Each separate object file will then be used as input to the linker, along with all referenced libraries to build the final executable.
  • error: member access into incomplete type

    help c++ database design debugging
    5
    0 Votes
    5 Posts
    7 Views
    Richard Andrew x64R
    Glad I was able to help! The difficult we do right away... ...the impossible takes slightly longer.
  • C++ Class method not working as expected

    c++ data-structures
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • C++ Class method not working as expected

    c++ data-structures
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • C++ file handling

    c++ learning
    4
    0 Votes
    4 Posts
    11 Views
    J
    Saboor Sarfraz wrote: but instead of moving the cursor to the beginning of the current line it moves the cursor to the next line Nope. A 'file' never ever does that. Rather you are attempting to display the file using something else. And that something else, not the file, is doing that. Saboor Sarfraz wrote: for the purpose of overwriting the existing txt. Your code is absolutely correct. For what you state the purpose is. So the problem is, as I stated above. If you are on a windows machine you can open a Powershell console or a 'cmd' console. They are NOT the same. Presumably you are using one of those then running your exe. So try doing it with the other one. If perhaps you are using an Apple Mac then you are perhaps out of luck since it always interprets the '\r' in the way you are seeing it behave.
  • 0 Votes
    3 Posts
    11 Views
    J
    Member 16142254 wrote: all sources are saying the application is of 64bit That is ambiguous. Your code is probably linking to some other dlls. I would first start with checking those. Member 16142254 wrote: launch the application You will have a main method. You can start by commenting ALL of the code in that module out except for the main() method call. So everything in the main() method is commented out also. If that runs then you can start uncommenting. If it doesn't run then it indicates that the build of that module itself is a problem.
  • &foo[bar] or (foo + bar) ?

    design question css com graphics
    22
    0 Votes
    22 Posts
    104 Views
    honey the codewitchH
    jschell wrote: Not sure what you mean. I mean this jschell wrote: If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer So I think somewhere we started talking past each other. Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
  • C++ reflection

    c++ com debugging question announcement
    9
    0 Votes
    9 Posts
    34 Views
    J
    honey the codewitch wrote: I'd probably still avoid it unless it solved a very significant problem Specific times I have used it in other languages. - Dynamic loading of classes. Especially when parameter lists are dynamic. - Messing with private data of a class. Most the time for unit tests, but I think one time it was in the production code. In C++ there is a way to do that anyways but it always risky and just as hacky. honey the codewitch wrote: Metadata ain't free. Which is why it has taken so long I suspect.
  • 0 Votes
    8 Posts
    31 Views
    J
    When I read the OP I was also wondering if they were referring to what you said or perhaps they thought the compiler would just figure it out.
  • 0 Votes
    9 Posts
    16 Views
    L
    SOLVED and CLOSED as initially asked for , by using named subgroup option. QRegularExpression re("(((?hci[0-9])(.*))?(?(([0-F]{2}[:]){5}[0-F]{2}))(.*))"); Thanks very much for all support given.