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
  • change C code from persistent to none persistent in HTML

    html sysadmin help
    3
    0 Votes
    3 Posts
    0 Views
    L
    Your server code doesn't even appear to be sending a header at the moment, so client will assume you are http 1.0 server and default of close connection. Look at the rosseta code for a Web server .. goto the C section .. you should recognize the code Hello world/Web server - Rosetta Code[^] The moment it connects to the client it sends a header to the client write(client_fd, response, sizeof(response) - 1); /*-1:'\0'*/ The header is at top of code and looks like this char response[] = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html; charset=UTF-8\r\n\r\n" "Bye-bye baby bye-bye" "body { background-color: #111 }" "h1 { font-size:4cm; text-align: center; color: black;" " text-shadow: 0 0 2mm red}" " Goodbye, world! \r\n"; So they are sending a header telling client the server is HTML 1.1 and will have persistent connections. The alternative is to send a 1.0 header with the keep-alive tag Then you simply don't close the connection until it times out. It's designed as a start point you need to flesh out the rest from there. In vino veritas
  • Calculating decimal places -

    help performance
    16
    0 Votes
    16 Posts
    0 Views
    L
    As per what David has explained all doubles are actually stored subtly different to what you think because they round. I just want to extend why they round. They round because the computer works in base 2 (0 and 1's) and you are working in decimal base 10 (0,1,2,..9) 10 does not work as a power of 2 you can go either side 2x2x2=8 OR 2x2x2x2=16 so any base 10 decimal fraction when written in base 2 will likely round Double-precision floating-point format - Wikipedia[^] Assuming you are on a standard Microsoft compiler many will be rounded at 52 bits long and we have no way to know what length you actually typed in. So usually when writing doubles to screen you fix the decimal places Here is how the standard print function does it the %.3f means take float write to 3 decimal places printf("Double value: %.3f\n", 3.1234543747321475); I have made a randomly long value but if you execute it only puts out 3 decimal places. There are many conversion routines in C/C++ to convert them in fixed decimal places to screen, buffers etc. So generally you fix the length at display or while the number is in string format, you can't work the problem in reverse the moment it stores the original length is lost. So basically once stored there is no way to count the decimal places .. you can't do what you asked. Lastly should add this is nothing to do with C, any language that stores numbers as doubles behaves that way. In vino veritas
  • Coding Contest for Women

    com question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Access a pointer value changed in another class

    question c++ help tutorial
    7
    0 Votes
    7 Posts
    0 Views
    CPalliniC
    Sorry ?!
  • 0 Votes
    4 Posts
    0 Views
    _
    Since the value of SIZE is constant and the same for all instances of the class, I suggest it be made a static const. That way you wouldn't need to assign a value to it in the assignment operator overload. static const int SIZE = <value>;
  • Can anyone tell me if c++ is worth learning?

    c++ question learning
    11
    0 Votes
    11 Posts
    0 Views
    M
    Try not to learn C++ for passing an exam or inspiring somebody, do it for the interest and the readiness to learn. You'll take in more and your advantage will increment. "Endeavor TO CODE IN THE IDE, MAKE MISTAKES AND LEARN". Again don't attempt to repetition or by-heart the stuff, commit errors and your mind will make affiliations that: "no doubt I committed an error while arranging that, it won't occur twice, that is the way you learn." My suggestion is follow this link to learn more
  • How to make a c++ executable

    question c++ tutorial
    11
    0 Votes
    11 Posts
    0 Views
    U
    use codeblocks instead it does the same thing as dev c++ but the .exe shows up in the project folder you can just drag it out and reditribute that
  • Conversion from C to C#, Need C# Method Signature

    csharp com help question
    3
    0 Votes
    3 Posts
    0 Views
    V
    Have a look at [DllImportAttribute Class (System.Runtime.InteropServices) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?redirectedfrom=MSDN&view=netframework-4.7.2) Some more ideas you can get from [c# - How do I resolve "Please make sure that the file is accessible and that it is a valid assembly or COM component"? - Stack Overflow](https://stackoverflow.com/questions/7080447/how-do-i-resolve-please-make-sure-that-the-file-is-accessible-and-that-it-is-a)
  • Make screen bigger

    c++ tutorial question
    13
    0 Votes
    13 Posts
    0 Views
    Richard DeemingR
    Hey, my printer's out of paper - can you print me some more? :-D "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Access a class instance based on its ID

    question data-structures
    4
    0 Votes
    4 Posts
    0 Views
    L
    So, I guess, packagequeue is the place to find it.
  • 0 Votes
    6 Posts
    1 Views
    M
    Destructor is as follows. WorkPackage::~WorkPackage(){ if (Wp_localstack.local_stack != nullptr) { Stack::release(Wp_localstack.local_stack); } } and release() is follows. void Stack::release(void * stack ){ int core_id= coreNumber::getInstance()->getCoreID(); //Get the thread id which called the dtor and release WPManagerProviderSingleton& singletonObj = WPManagerProviderSingleton::getInstance(); WorkPackageManager &wpm = singletonObj.getWpmInstance(core_id);//Based on thread id, select the workpackage manager(every thread has its own manager) to deallocate the stack from its respective Memory pool wpm.PerThreadMemPool.DeAllocate(stack); }
  • C Programming

    4
    0 Votes
    4 Posts
    0 Views
    S
    The c programming is the oriented language which will be going to proceed it for the user which will be going to work for implementing the part which will be more important to exaggerate it so hp support australia will guide you to make you understand the part for the valuable aspects which will keep the user enthusiastic for the work.
  • Break when address reading

    tutorial debugging performance
    8
    0 Votes
    8 Posts
    0 Views
    _
    The first thing that came to mind is to search for g_iNum in the entire code base and put breakpoints where ever it is being accessed. ;P «_Superman_»  _I love work. It gives me something to do between weekends. _Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
  • Thread synchronization problem

    question help
    16
    0 Votes
    16 Posts
    2 Views
    _
    Since the tasks are not waiting on any object or variable, there will be no dead lock. I guess you do need to add if (rcvd == false) in task B before the line rcvd = true; «_Superman_»  _I love work. It gives me something to do between weekends. _Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
  • CAsynSocket Client Question

    question
    4
    0 Votes
    4 Posts
    0 Views
    V
    You may want to read this great Joe Newcommer essay: [An MFC Asynchronous Socket Example Done Right](http://www.flounder.com/kb192570.htm)
  • What are Destructors in Object-Oriented Programming

    com tutorial
    2
    0 Votes
    2 Posts
    0 Views
    D
    yaseen ramzan wrote: is it a correct about destructors Yes. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • Want to learn C. Newbie. Where to start?

    learning visual-studio tutorial question
    30
    0 Votes
    30 Posts
    0 Views
    L
    Yeah I understand, and yes willing to do the hard yards learning is much more important. I am so old I can do long division and work without an IDE but if I am honest I am just not sure it means much. Of the younger staff around me I am not sure how many can actually work without IDE (or do long division) not something I had ever found I needed to ponder. In vino veritas
  • 0 Votes
    7 Posts
    0 Views
    M
    Thanks alot it worked
  • What Is Bitdefender Central And How It Is Used??

    help question com
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    8 Posts
    0 Views
    V
    Then use ShellExecute(Ex).