Im looking for a method of get the effective size of a dinamic array created with the new statement, because the sizeof instruction only gives me the size of the pointer or the size of the first element of the array, maybe that i don't know how use that, but i really want to know the size of an array without having the number of elements of the array, (if it's posibble) the same as UBound property in VB6.
PS: excuse if this text is a little confuse, i'm from argentina and my english is basic.
The C++ inside me says:
Better to use some class for holding the array (what about ready-to-use stl::vector?) that could return you the size of the array by using something line myArray.size()? You will also get the automated memory management included and many more other stl usefull functions.
The C devil says:
on most compilers, the size of the array is stored at some negative offset of the array (but differs on compilers, also can differ on compiler versions etc - simply don't try it at home, it's ugly ugly ugly hack - just mentioned in case of emergency)
For future reference, take a look at the inet_addr function in the MSDN library. I can't believe there isn't built in global c runtime functions for parsing an IP address in this day and age. But if you are programming with MFC or windows, you can use this windows function.
I hate the sscanf method myself. It seems wonderful on paper but there seem to be all kinds of weird issues when I try to use it. It never worked well for me as a validation tool for any kind of number. I always use the cruntime methods such as strtod for taking strings and validating them as actual numbers and converting them into an int value (for instance). Unfortunately, I don't see a c-run time method for IP addresses that would be more portable. Since I am a windows programmer, I have to settle for the windows libraries to provide this capability.
Question. I have been doing c++ code for sometime now but only in console code. I am starting now to use MFC and I wanted to convert my old Console code into GUI MFC code. My Code relies heavily on Stream I/O with strings and character arrays, but I am having a problem getting my character arrays to output to my GUI correctly. I keep getting assertion errors when when running the program (NOTE: the program compiles error free).
Actually, the assignment operator works for both strings and characters, as per the MSDN documentation.
So you can simply do a:
m_strKey = key;
m_strKey = key;
As mentioned in the other reply, CString::Format is CString's version of sprintf(). You can use it to assign a string (as you did), since it didn't have any formatting characters in it. But CString is flexible enough that you can simply assign directly via =.
I also played with the UpdateData(), but again it will only output the last character I send which in this case is "e". "T" gets lost somewhere along the lines even if I send it by sending FALSE to UpdateData().
In the second case you are using a format string that only accepts one
character then passing two characters as arguments (of course only one is used):
m_strkey.Format("%c", key, key); //Output "T" and "e"
m_strkey.Format("%c%c", key, key); //Output "T" and "e"
I would lose the calls to UpdateData(). Rare is the case that it is ever useful.
You did not indicate what control on the dialog box is displaying the text so I will assume it is an edit control. In the dialog's class, you need a CEdit variable (e.g., m_edit). Now your code can look like:
Is there a way, in a Visual Studio .NET Setup project, that you can make a custom folder under the Application folder that will include all the files from some source directory? I only see a way of specifiying individual files to add to the folders. I just want this folder to include c:\somefolder\*.* and not worry about adding and removing individual files if it changes.
Last Visit: 20-Sep-20 13:21 Last Update: 20-Sep-20 13:21