|
Hello everybody
I have one Function that returned one char* value.
In this function I declare one char* variable and new it.
Like this:
char* CProject::Myfunction(CString strData, CString strPassword,int iRand)<br />
{<br />
char *chResult=new char[strlen(chDataString)/2];<br />
. <br />
.<br />
do something on chResult<br />
.<br />
.<br />
return chResult;<br />
}
In end of function I must return this value.
Where I can delete this pointer?
Pleases help me.
With special tanks and excuse for my bad English language
Good luck
|
|
|
|
|
Hi,
not in this funtion.
some where you have the line
char *line = Myfunction(.....);
than you use the line and after it, you delete it via
delete[] line;
I hope it works
|
|
|
|
|
The caller of the function must delete it.
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.
|
|
|
|
|
samira samehforooghy wrote: Where I can delete this pointer?
I believe you could delete it in the function which calls your Myfunction .
char* ch = Myfunction(...);<br />
.....<br />
delete ch;
Hope this helps.
---
Hakuna-Matata
It means no worries for the rest of your days...
It's our problem free, Philosophy
"I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
|
|
|
|
|
thanks for your answer
i will be test them
|
|
|
|
|
When you don't need it anymore....
Steve
|
|
|
|
|
and in this case:
CString str= Myfunction(.....);
?????????????????????????????
|
|
|
|
|
In that case you must change Myfunction() to return a CString , or you will have a memory leak.
|
|
|
|
|
markkuk wrote: In that case you must change Myfunction() to return a CString, or you will have a memory leak.
Actually the above is not completely true: provided you follow the baerten [^] suggestion the code will work fine.
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.
|
|
|
|
|
char *temp = Myfunction(....);
CString str = temp;
delete[] temp;
Because i THINK CString copies the char's into his own locatet memory.
So you lost the pointer to the allocated memory of the funtion Myfuntion,
You need to save temporary the pointer, only to delete him.
|
|
|
|
|
how to run a command using shellexecute in administrator mode ie c:\windows\system32
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Hello
I know its very basic question , i am very assamed for asking this question
But i don't have any other option so....... My problem is that
I am making an applicaton in vc++ 6.0 and now my application is almost
complete.
Now i need to setup it to client mechine.
Can any one told me what necessary MFC .dll are required for this , and what is net link for downloading these .dll
What special for instrolation these .dll.....
Note : My MFC Application id modal dialog based
Regard's
Kaushik
|
|
|
|
|
I need :
mfc71d.dll
msvcp71d.dll
msvcr71d.dll
But, if you start the application, the error-message tells you which files aren't present.
You can also built you application with'in the MFC (so the MFC is staticly linked into you app)
Since now i never tried it, but it's a basic "must"
Because if you download a .exe you never have some mfc DLL's delivered with
Good luck
|
|
|
|
|
You can use dependency walker[^] to check which dll's are needed.
If you use VC2005 you'll need to run vcredist_x86.exe instead (that will install the run-time libraries and MFC dll's).
|
|
|
|
|
Thankyou so much
Regard's
Kaushik
|
|
|
|
|
Hello
I know its very basic question , i am very assamed for asking this question
But i don't have any other option so....... My problem is that
I am making an applicaton in vc++ 6.0 and now my application is almost
complete.
Now i need to setup it to client mechine.
Can any one told me what necessary MFC .dll are required for this , and what is net link for downloading these .dll
What special for instrolation these .dll.....
Note : My MFC Application id modal dialog based
Regard's
Kaushik
|
|
|
|
|
If you link against static version of the MFC class library then you don't have to distribute the library itself.
To Link against static version of the MFC:
(1) Choose the Settings item of the Project menu.
(2) Select Use MFC in a Static Library item of the combo box below the Microsoft Foundation Classes label.
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.
|
|
|
|
|
my code
<br />
<br />
class A<br />
{<br />
public:<br />
int i;<br />
<br />
};<br />
<br />
class B<br />
{<br />
public:<br />
A m_A;<br />
<br />
void f(A a);<br />
};<br />
<br />
void B::f(A a)<br />
{<br />
m_A = a;<br />
return;<br />
}<br />
<br />
<br />
main()<br />
{<br />
B b;<br />
A a;<br />
<br />
b.f(a);
<br />
<br />
}<br />
<br />
|
|
|
|
|
It works fine, at least on my system...
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.
|
|
|
|
|
because my class A not have a default copy constructor
|
|
|
|
|
Sorry you didn't got it.
Hi,
This is because you have enabled RUN TIME check for uninitialised variables /RTCu.
In your code just put the following
int i;
int j = i;
You will get the same runtime error as before as you used variable "i" uninitialised.
Or disable RTC in your project setting.
Default copy constructor means by default it has it. You write a simple constructor (not copy contructor) you won't get this error.
Ultimately this error is caused because of the uninitialised member of class A and you have enabled RTC.
Best Regards
Raj
|
|
|
|
|
|
VC++ 6.0 class view pane not displays all classes in the project.
biju mathew
kattappana
|
|
|
|
|
bijumon Mathew wrote: VC++ 6.0 class view pane not displays all classes in the project.
Try this:
Close the IDE and delete the file which has an extensio of .ncb and re open the project. You should have all your classes displayed.
Hope this helps.
---
Hakuna-Matata
It means no worries for the rest of your days...
It's our problem free, Philosophy
"I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
|
|
|
|
|
Hi all
I have CString type Buffer ,fname Now i want to copy the contant
of buffer in to fname
Note : One think more impportant i am saving the file in to local HD using
this
fileObj.Open("c:\\UserFolder\\" + fname + ".txt",CFile::modeCreate,NULL);
I want to save file with the fname and also copy the contant of buffer to fname
Can any one told me how can i do this.
Regard's
Kaushik
|
|
|
|