For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I need to debug an embedded C-application that contains a lot of the following structs:
I have ported the code into a Visual Studio 2005 console application and I would like to dump all the struct-members (several hundred in total) to a text-file like this:
MyStruct.MySubStruct.MyEnum = MyEnumValue
I know this isn't possible in pure Visual Studio c programming language, but aren't you allowed to include C++ files as well in a Visual Studio console project? If so, is C++ capable of converting struct members and enums into text strings?
And your code above does not make clear what the problem is in sending the struct contents to a text file. Generally speaking you need to write the code to dump each element of the struct. Or you could just run the program in the Visual Studio debugger and examine the fields that way.
However you are not really giving me enough information. You need to be very specific when you ask for help. Do you need to do this on a Release build or Debug build? Do you need to do this at run-time or compile-time?
1.) Preprocessor abuse[^] that stores the variable name in an extra char field in the struct. Here is a partial example[^].
2.) If you are using C++ there are several boost libs[^] that allow you to implement some reflection.
3.) The Debug Interface Access SDK[^] can be used to get all of the structs and member variable names. If you go this route... you will need to generate a PDB.
If this is a debug tool I recommend that you check out the Debug Interface Access SDK[^] which will allow you to get all kinds of useful information and statistics about your executable. You can dump each function/class size and type along with the variable name.
I need to "send" data in a notepad every time I write double numbers on edit control and press save. I wrote some code but my dialog (where the edit control is) don't even open when I run the executable. What I've done so far:
// TODO: If this is a RICHEDIT control, the control will not// send this notification unless you override the CDialog::OnInitDialog()// function and call CRichEditCtrl().SetEventMask()// with the ENM_CHANGE flag ORed into the mask.// TODO: Add your control notification handler code here
I think I must write some code here so the dialog box work fine but I can't it.
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
Just get the text from the edit box using GetWindowText:
// If you have a class member variable for the CEdit in your CDataDialog class:
// If not, you have to use the ID:
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_OF_THE_EDIT_BOX);
I did it but I didn't manage to save them again. Also when I pressed <x> this message appeared: "Exception thrown at 0x104420C5 (mfc140ud.dll) in Input.exe: 0xC0000005: Access violation reading location 0x00000020.
If there is a handler for this exception, the program may be safely continued.------>Break, Continue, Ignore"
Then use the debugger to see what happens (e.g. by setting a break point somewhere after the output file has been selected using the CFileDialog). You might also check if file.Open was successful. But if that fails calling file.WriteString should throw an execption.
How can I give data in a dialog box dynamically? In a previous project I used edit boxes (e.g for 3 conductors) and gave those data separately for each conductor but now I have to give them dynamically and I don't have standard number of conductors and I can't use edit box again. Could you please give me an idea or a good link describing step by step how to create a table in a dialog box dynamically?
Thanks for your time!!
I have created a dialog box in which I insert data about conductors (resistivity, permeability, diameter etc (electric power systems )) in edit boxes but I have done it only for 3 conductors. I have to insert-edit the number of conductors and then edit their characteristics. But I can't use again edit boxes because this is static. I want something like a dynamic table which will have rows=number of conductors and columns about is characteristic (resistivity, permeability, diameter)and edit them in dialog box. I don't know how to upload my executable to male clear what I have done but here is a part of my code for the static case of three conductors I want another dynamic way to edit data :/
Good Morning Sir,
can we use std::string for handling names like chinese letters, japanese letters? I mean we can use them for string comparison like "some chinese stuff"=="some chinese stuff" will it work?? Thank you sir for your time excuse my english
It depends what encoding you use for the Chinese characters. If it is Unicode then you need wstring, but if it's UTF8 then you will need to create a new type based on basic_string. Look at the samples in the link I gave you.
The function name CALL_MD5_Function indicates that it is calculating an MD5 hash sum. But that algorithm is a binary operation and usually requires passing a byte array and a length. With C/C++ char* pointers are often used to pass byte arrays (using uint8_t* would be better). So a char* is not always an indication for a string type.
You are calculating the hash for file names which use different encodings on different platforms (e.g. UTF-16LE on Windows and UTF-8 on Linux). In such cases you have to know (or define) which encoding has to be used for calculations of the hash sum. Then you have to convert the file name strings to that encoding before calculating the hash sum. If it is used only on a single platform, just cast the wide string pointer and pass the length in bytes (the length is missing in your function call; I assume it is just a wrapper to the real function passing strlen).
Finally, why do you want to get the MD5 sum of file names?
It is usually calculated for file content which is just binary.
No, sir the function will get the MD5 of the file itself, not for the names of the files. I am on a windows platform and this function is not going to be used for *nix platforms. so what shall I do sir
You can when using the appropriate char types and encodings.
Use std::string<char> (std::string is a typedef for this) for ANSI and multi byte encodings like UTF-8.
Use std::string<wchar_t> (std::wstring) for wide character Unicode strings. Note that this is platform dependant. With Windows, wchar_t is char16_t while it might be char32_t on other platforms.
It depends on your project settings (Unicode or ANSI / multi byte), the used encoding / code page if not a Unicode project, and what the library supports. If you have a Unicode build (recommended), there is probably also a Unicode version for the library.
If the library does not use the same encoding as your project you have to convert the strings.
Inside your program, the best way to represent characters is using the wchar_t-based types (e.g. std::wstring). This enables simple processing (all characters are represented by a single wchar_t value), and so on.
If you wish to call a library that only supports char-based types (e.g. std::string), you must convert whar_t types to char type, call the library, and convert the results back. In C++11, the standard way to do this is something like this: