|
0. your formulae for y and z look ok
1. Do not use malloc (or any other alloc function) to allocate memory for POINT3D or any other class (or struct, which is essentially the same) type! Any class or struct may have constructors and destructors, neither of which will be called when using standard C allocation routines! Even though you didn't explicitely define either, the compiler does create some for you. And besides, you may want to add constructors or destructors later.
2. Don't use realloc, especially in the way you did (you're forcing a realloc on every single iteration of the loop!). Use standard container classes instead, such as std::vector (call #include <vector> ). They take care of reallocation and are orders of magnitude more efficient at it.
3. What happens with the rest of lines that do not start with '1'? Looks like the loop will just try their best on the rest of the line rather than skip to the next line. As there is no check on the number of inputs per line this will mess up the remainder of the input, as will any other unexpected mistake in the input file. Unfortunately the stream operators >> are not that helpful in this regard, check the member functions instead.
4. Your code is truncated.
6. Don't use global variables; the point arrays should be members of your revolution surface class. What would you do if you had two objects of type Revolution Surface?
7. A minor issue: make sensible objects and name them appropriately; a class that represents a 3D revolution surface is sensible, but what is the name 'RevolutionProjView' meant to indicate? What it does indicate is that this object is a view, which it is clearly not. Nor is it a projection. Why not just 'CRevolutionSurface' ?
Also the function name 'drawProfile' seems entirely inappropriate as it doesn't draw anything. Did you mean 'readProfile'?
|
|
|
|
|
Hi,
How to free the memory if memory is allocation using memset.
suppose,
ulong m_ularr[]; //declaration in header file
//In constructor we allocate memory as
memset(m_ularr, 0, sizeof(m_ularr));
Kindly help me how to free the memory in destructor for this one.
Freda
|
|
|
|
|
memset() doesn't do any allocations. Your array is allocated on the stack and will not require any deallocations. Only when allocating memory with an allocation method such as new/alloc/malloc/or other platform specific allocation methods, you will have to deallocate accordingly. memset() only writes data to a piece of memory that should allready have been allocated by you if you've done it properly.
|
|
|
|
|
Before worrying about memory deallocation, you should make sure you're writing (memset just writes) on previously allocated memory (in your code memory is never allocated).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
You dont need to free this memory, it is static.
You only need to free heap memory which you allocate with a new, or malloc, or alloc. (Use delete free and free respectively).
Or of course if you use smart pointers, which automatically free when they stack container goes out of scope, there isnt a need for a free, but thats getting a bit beyond your question.
==============================
Nothing to say.
|
|
|
|
|
I'm not a c++ programmer, but I need to be. I wrote a dll for installshield, that installs the web server program using shell as a custom action, but when I use their (IISHelper.dll) dll for programming the website, I run into problems. Thus I should write my own stuff in the same custom action.
So I working with some sample code, that gets the object, but the sample code returns the HRESULT, and not the object, unless the object is IIS_IADs, like getting the value of a registry key?, in which it's there but you have to sort of dig it out.
For now, I want to grab the default website in IIS5.1, and change the virtual path, the path to the code, and set the documents, mimes and so forth. If I can figure out how to grab the master object, I think I can program the rest and write the values.
hr = ADsGetObject( L"IIS://localhost/w3svc/1/root", IID_IADs, (void **)&pADs );
if ( FAILED( hr ) ) {
app_Level = 1;
goto error;
}
|
|
|
|
|
I think what you are talking about here is a COM object, which is a little different to a C++ object. I don't know enough about it to explain further, however, so i will let someone else do that .
But as far as i know, the "object" is returned as the pADs pointer, you need to cast it from void*
|
|
|
|
|
without seeing more code, pADs is the variable that will be holding the com object you want to manipulate. pADs is likely a pointer to some COM interface (if you're not sure what that means you'll have to read up on the c/C++ langhuage and how to use pointers), thus the use of
&pADs
the "&" means you're taking a reference to something, so a pointer to a pointer. That's how all (or most) of the COM API functions work - they return an HRESULT to indicate the success or failure of a call, and if the function is supposed ot give you back an object, then it's done like this, with a pointer to a pointer of some interface.
|
|
|
|
|
ohoooo
That was sort of like the registry function I wrote, In which it returns the Success code, and the object in the function contains the data.
Much different than VB or C#, or JavaScript.
Is it possible to export that com object, and pass it to another function for further processing?
HRESULT CA_WebInfo::get_IIS_VirtualDirectories( DWORD InstanceID ) {
HRESULT hr = CoInitialize( NULL );
if ( SUCCEEDED( hr ) ) {
USES_CONVERSION;
CComPtr<IADs> pADs;
CComPtr<IISApp2> pApp2;
WCHAR ADSIPath[50];
wsprintfW( ADSIPath, L"IIS://localhost/w3svc/%d", InstanceID );
hr = ADsGetObject( ADSIPath, IID_IADs, (void **)&pADs );
if ( SUCCEEDED( hr ) ) {
};
pADs = NULL;
hr = ADsGetObject( ADSIPath, IID_IADs, (void **)&pADs );
if ( SUCCEEDED( hr ) ) {
hr = pADs->QueryInterface( IID_IISApp2, (void **)&pApp2 );
if ( SUCCEEDED( hr ) ) {
CComBSTR bstrVarname = L"Path";
CComVariant varAppRootPath;
hr = pApp2->Get( bstrVarname, &varAppRootPath );
if ( SUCCEEDED( hr ) ) {
}
};
};
};
CoUninitialize();
return hr;
}
|
|
|
|
|
Yes, it's just like any other parameter, though you do have to be careful to keep track of the ref count.
Also, are you sure you want to be initializing/un-initializing COM in the one function? Wouldn't it make more sense to put that in your modules startup/shutdown code?
If get_IIS_VirtualDirectories is part of some other COM object (implemented in C++) then CoInitialize should already have been called, making your call redundant. If the code has to execute in another thread, then you really want to put the CoInitialize call in the thread's initialization before it starts doing anything else (and you don't want to use CoInitialize, you'll want to look at CoInitializeEx and use the multi-threaded settings).
|
|
|
|
|
I was using the code sample to try and sort of reverse engineer some sample code, and get a clear understanding of it first. The Big Picture is that I'm trying to write my own Custom Action DLL for InstallShield Pro, that installs the web server, looks at the metadata, if it's XPPro/Vista/7 with 1 default website, then change the virtual path, program the mimes, documents so my asp.net product will work.
I didn't know what the scope of coinitialize was, or what it does, and I prefer to just write 1 giant function first.
I wrote this first, as the main function, in which I want to fork out to another function based on the IIS Version installed. But I'm stuck creating my first engine function, that does the work. in switch case 5, I want to run the IIS job.
void CA_WebInfo::create_WebServer( CString msi_DIR_AppVolumeFolder_II ) {
bool iis_Result = false;
int program_ExitCode = 0;
unsigned long iis_MajorVersion;
unsigned long iis_MinorVersion;
CA_Registry caReg;
iis_Result = IIS_Installed();
if ( iis_Result == false ) {
program_ExitCode = install_WebServer( msi_DIR_AppVolumeFolder_II );
}
iis_Result = IIS_Installed();
if ( iis_Result == true ) {
iis_MajorVersion = caReg.get_IIS_MajorVersion();
iis_MinorVersion = caReg.get_IIS_MinorVersion();
int result_ADSI = 0;
switch ( iis_MajorVersion ) {
case 5:
attach_IIS5_XP();
result_ADSI = get_IIS_VirtualDirectories( 1 );
break;
case 6:
break;
case 7:
break;
}
}
}
I know I have to attach to the metadata first, see what it is, and then take action. I have written this in VB with great success, but c++ is lights years away. This is my intialization of the IIS MetaData.
I hope my explanation makes sense, this is my first c++ project since 28 years ago.
HRESULT CA_WebInfo::attach_IIS5_XP(void) {
HRESULT hr;
IADs *pADs = NULL;
IISApp2 *pApp2 = NULL;
IISApp3 *pApp3 = NULL;
DWORD instanceID = 1;
int app_Level = 0;
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( FAILED( hr ) ) { goto error; }
hr = ADsGetObject( L"IIS://localhost/w3svc/1/root", IID_IADs, (void **)&pADs );
if ( FAILED( hr ) ) {
app_Level = 1;
goto error;
}
hr = pADs->QueryInterface( IID_IISApp2, (void **)&pApp2 );
if ( FAILED( hr ) ) {
app_Level = 2;
goto error;
}
hr = pADs->QueryInterface( IID_IISApp3, (void **)&pApp3 );
if ( FAILED( hr ) ) {
app_Level = 3;
goto error;
}
error:
if ( pApp3 )
pApp3->Release();
if ( pApp2 )
pApp2->Release();
if ( pADs )
pADs->Release();
CoUninitialize();
return hr;
}
|
|
|
|
|
hi ,
i made a simple application for encryption and decryption of a text file using c language.
i want to know if a text file contains language symbols other than English , than how C language take care of it. Please also tell me if we can add other languages support in C language.
|
|
|
|
|
Check out http://en.wikipedia.org/wiki/Unicode[^]. You may want to use strings of unicode characters rather than just char Of course then you will also have to figure out and use encodings. Here's a good introduction on Unicode and encodings: http://www.joelonsoftware.com/articles/Unicode.html[^]
I'm probably not the best person to ask about what libraries and system functions to use, but it shouldn't be too hard to google for. I do know Visual Studio provides built-in support for unicode strings, it's right in the project options.
|
|
|
|
|
|
Hi Dveleopers,
I have some problem regarding combo-box control. In one situation it give the list properly and in the other one it appears till the mouse is hold after that it get hides. If we click on arrow part of combo box it behaves properly, but if we click on the text part it give the list while mouse is in hold after that it get hide.
In 1st condition I have added almost 15 items and in other situation almost 500 items is being added.
The only difference between these items is that 1st one is CString and the 2nd one is char*.
Here the sel change of another combo based on that combo box ""m_chap"" ( in which I have problem is being populated ). pFnameMap is a structure and pFnameMap->fullName is a char*.
CString szTemp;
m_nUserType = m_Rep.GetCurSel();
m_Chap.ResetContent();
if(m_nUserType != LB_ERR)
{
m_Rep.GetLBText(m_nUserType, szTemp);
if (szTemp.Find("Materia") >= 0)
{
FNAMEMAP1 *pFnameMap = NULL;
for( int i=0;i& heApp.m_ChapterNameMap.GetCount();i++)
{
if(APP->m_ChapterNameMap.Lookup((WORD)i,(void near *&)pFnameMap))
{
if(stricmp(pFnameMap->repName, "Complete")==0)
{
m_Chap.AddString(pFnameMap->fullName);
}
}
}
}
else
{
szQuery = "Repertory = '" + szTemp + "'";
m_pRsRepChaps->SetFilter(szQuery);
while(!m_pRsRepChaps->IsEOF())
{
m_pRsRepChaps->GetFieldValue("Chapter", szTemp);
if(m_Chap.FindStringExact(-1, szTemp)==LB_ERR)
{
m_Chap.AddString(szTemp);
}
m_pRsRepChaps->MoveNext();
}
}
}
Combo box style is dropdown.
Thanks in advance.
Amrit Agrawal
Software Developer
|
|
|
|
|
When do you add the items?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hi there,
I've got a trouble of memory leak. I use Process Explorer to watch my app's status, and find that the "virtual size" keep increasing, and get to 2GB eventually, but the app never crashed.
I use windbg to check the app's memory status, the memory committed and memory reserved are also good(130MB),in my understanding, the "virtual size" is composed of the memory committed and reserved,but the fact is not. Please tell me how to calculate "virtual size", Thanks very much!
|
|
|
|
|
|
|
|
Hello community,
i use this function in my application and have a little issue!
For example Firefox translate URL with tis "ö" to "%C3%B6" and this is ok, now when i use AfxParseUrlEx with URLs who have character like "ö" in this convert it to "%F6" and this is wrong!
I need it converted like Firefox from "ö" to "%C3%B6"!!
Hove to use AfxParseUrlEx so that they should do the same like Firefox?
Use with parameter ICU_BROWSER_MODE don't work!
I hope my question is understandable for other
Best regards
bosfan
|
|
|
|
|
What happens if you set dwFlags to 0 ?
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hello,
thanks for answer! It is the same, character 'ö' is converted to
"%F6" not to "%C3%B6"! Maybe i do not understand this function!?
For example, blanc's are converted to "%20" and this is ok!
regards
bosfan!
|
|
|
|
|
"%C3%B6" is a two byte character, perhaps the issue has something to do with character encoding (UTF-8 vs UTF-16)?
Edit: I see that 0xF6 (246 decimal) is ASCII character "ö".
|
|
|
|
|