|
So you mean to say in VS2003 or VC++ 6 the first memory block will be still occupied ?
redindian
|
|
|
|
|
i would have thought so as you haven't freed it explicitly, or your compiler has done it for you, why don't you put cout << "destructor\n"; in your destructor and see?
paul
if ignorance is bliss then knock the smile off my face!!!
|
|
|
|
|
dharani wrote: When a "new" is called second time to allocate 20 bytes what will happen to the first 30 bytes allocated ?
The allocated memeory will become inaccessible (and thus un-deletable), because you do no longer have a 'handle' to it.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
So how to avoid such a scenario ?
I am trying to find answer ...
redindian
|
|
|
|
|
dharani wrote: So how to avoid such a scenario ?
<br />
delete[] the old memoryadress before reallocating.
Hold the new address in another variable.
Use a string class (e.g. std::string or CString ), which handles the memory for you.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Use realloc .
Regards,
Paresh.
|
|
|
|
|
You shoudln't mix new and realloc.
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
Yes, you are right. I was thinking in malloc context.
Regards,
Paresh.
|
|
|
|
|
swathee wrote: You shoudln't mix new and realloc.
offcouse..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
Use std::string instead of char arrays.
|
|
|
|
|
dharani wrote: I am trying to find answer ...
CString is much better optimized in this case!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
Hello Friends,
I have a problem Want your views on that.I have a ftp client software(FileZila) that download the file from specified FTP Server for View/Edit in a temporary folder.It has a functionality( A problem in my case !!!) that when u edit the file and save, it doesnt save the file directly on FTP Server, rather it save on temp(Windows Temporary) Folder and when you close the window then only it ask to upload the file ( i.e. save the file on the FTP server). I have a got the task to implement the functionality that save the file on FTP server when you save the opened file. I am using FindFirstChangeNotification function to monitor the Temp folder. but it has to problem as follows.
1)it generates the Event(message) when u open the file(i.e. Download the file)
and the another one and the most important.
2)How do I upload the file which is opend and under work when somebody save that file( only save!. not close!!).
If u have any suggation please send me,
|
|
|
|
|
why not make a copy of the file and then upload that file?
Yours Truly, The One and Only!
|
|
|
|
|
_NightOwl_ wrote: why not make a copy of the file and then upload that file?
Genrally when file is open in Exclusive mode, it doesn't allow other process to even read from it
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
I'm using the date control on a dialog. When the dialog is displayed I need to set the day field of this control to be selected. Can anyone tell me how to do this?
thanks,
Andy
|
|
|
|
|
Are we talking about a CDateTimeCtrl here?
Normaly, you call SetTime() on a control-variable of type CDateTimeCtrl you added to your dialog.
This would require the time you want to set in a CTime or COleDateTime class or a SYSTEMTIME structure.
Another, more complicated, way would be to send the control a DTM_SETSYSTEMTIME message.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Use GetMonthCalCtrl to get CMonthCalCtrl from a CDateTimeCtrl. Use SetCurSel to select a date.
Sample from MSDN:
CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(IDC_DATETIMEPICKER1);
CMonthCalCtrl* pMoCalCtrl = pCtrl->GetMonthCalCtrl();
CTime dt2(1998, 3, 15, 0, 0, 0);
pMoCalCtrl->SetCurSel(dt2);
- NS -
|
|
|
|
|
ok, I think I may not have explained it clearly enough, what I need is for the day field of the control to be selected (i.e. if the user types then the day changes). I'm using a Date Time control which is liniked to a CDateTimeCtrl object.
cheers,
|
|
|
|
|
ShowWindow(SW_MAXIMIZE)Not working properly in 98 machine. ShowWindow(SW_MAXIMIZE) Maximize my application is draw only half of the desktop(screen).If any one know this pls help me.
|
|
|
|
|
Viknaraj R wrote: Not working properly in 98 machine.
Did u have tested it in other OSs? What kind of window you have?
- NS -
|
|
|
|
|
it work properly in xp My window is a dialog in vc++
|
|
|
|
|
Is there any custom painting?
- NS -
|
|
|
|
|
I have a little application called updater.exe. This updater gets called by the other application called someapp.exe. Updater receives three arguments
1. calling application (full path of someapp.exe)
2. location of the installer file
3. installing destination folder
So when someapp.exe calls updater.exe it immediately exits (it will get overwritten). Because this exiting process isn't instant, updater should check if it's still "alive". How can I do this? Can I get some handle from 1st argument and check if application is still running?
Best regards,
Rostfrei
|
|
|
|
|
Will this[^] helpful ?
Regards,
Paresh.
|
|
|
|
|
You could use a kernel object, as describes by Christian Graus here[^].
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|