Okay ...I was working on making my own string class using dynamic memory allocation. The things were working fine. But when I sent the same code to one of my friends the code crashed. He was using the same compiler. The then copied pasted the same code in another source file, so it crashed. Then I changed the name of the original file, again program crashed. But I changed to name again to previous one and then again program was working fine. so whats this whole thing. c++.
P.S: I have dynamic memory and pointers.
Yes, you should be able to create a C++/CLI Assembly (DLL) which exposes functionality to C# via ref classes. Those managed classes can call into the C/C++ SDK to do the necessary work. Reference the C++/CLI assembly from your C# code and call into it... profit!
I created a library with Entity Framework 6 in C# recently, and now I would like to use it with a C++ program. Consequently I though about using C++/CLI to reuse my C# code, translating it easily. Is it a good/logical choice? I'm not sure because I don't know much about C++/CLI.
I'm trying to follow the steps I used to create my C# library. Now I'm stuck with adding the element "ADO.Net Entity Data Model" to my project in Visual Studio 2015. How can I do that?
I couldn't find any tutorial about using Entity Framework with C++/CLI, that's why I'm a bit lost.
Rather than wasting the time of busy professionals, why not give this a try yourself? You might actually learn something (even if that something is that you only know how to start the program off and not how to finish it, showing you where you need to study more). This site is CodeProject, not RentACoder.
I have a server client application using TCP/IP sockets in MFC VS2017. Originally i have written the code in VS2008. Kindly see the below code which sends the data to client. But this same code gives me some problem in MFC VS2017.
In the below code when I assign the value 190.000015f to a local variable, its taking the value whereas when I assign it to the union member variable
, it showing some junk value. Please help me to fix the problem
Probably a problem of structure packing / data alignment. With C/C++ structures and unions, member data are aligned by inserting padding bytes. How many bytes are inserted depends on the used compiler options where the default settings depend on the platform (CPU type and bit width).
When sending such structures via network to other systems, you must ensure that sender and receiver use the same packing / alignment. This is usally done by setting the alignment to one byte.
With Visual Studio use the #pragmapack[^] directive:
// Save current setting and select 1 byte
#pragma pack(push, 1)
unsigned char Buffer[LIVEUNISIZE];
// Restore previous setting
Note that this might fail with existing (old) versions of your server and client. If so and you have to support old versions, you must check which alignment has been used and select that for packing.
This forum is for managed C++ / CLI but your post would fit in the C++ / MFC forum.
I question how you are determining it is wrong. You code does not demonstrate that.
You are declaring a data entity on the stack. Then you are RETURNING part of that data entity from the method.
That is ALWAYS wrong.
And I suspect that is your problem.
The calling code also uses the stack. And will reuse exactly the same memory as where you are attempting to put a value if it wants to. For example if you are calling a method to 'print' the returned value in some way. Thus overwriting it. And that would cause a "junk" value either now or in the future.