|
namaskaaram wrote: assigning name =NULL and then deleting it will give u an error since u r trying to delete a block that points to the null address!!!!
rather the code should be more like.....
Do you know basic of pointers.........?
Ashutosh
|
|
|
|
|
namaskaaram wrote: int main(){char *name = NULL; name = getmestring(); cout<<name<<endl;if(name !="NULL)delete" []="" name;}<="" blockquote="">
change it to
if(name != NULL)
delete [] name;
name=NULL
"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
|
|
|
|
|
Since you are using C++, why mess with char at all? Use std::string instead and you won't have these silly memory issues.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hello! I'm a c++ beginner, and i'm trying to encrypt a simple text file, but, as I search in the internet, there are a lot of algorithms that I could use... so I'm a little bit confused... Can you tell me wich one is the best for me?
The file can be encrypted / decrypted with a Key or passhrase. Maybe using a symmetric algorithm ?
Well, I hope you could help on this..... Thanks a lot!
Aby Skaria
|
|
|
|
|
Jean-loup Gailly algo!.....u can get their free lib!....
click this[^]
dont want,dont want thinking,climbing on head and jumping grass!
(venda venda ennu vicharikumbol thellayill keyaree chadunnoda pulle!)
|
|
|
|
|
hello..! Well most often in encryption the longer the key the better. So that brute force will not be applied on your encryption algorithm. You should consider security threats before deciding which one to use.
-------------------Life is simple, You just complicate things --------------
|
|
|
|
|
Hi,
I have build the application using MFC, VC++ 6 on Windows XP. It is runnign fine in on my system. But it get crashed on the cleint side (operating system Win2K) but sometimes it worked fine .cleint is too far from me, I cannot debugg it personaly over there.
How can I check it that at which pont it is crashing.
Thanks
Regards.
|
|
|
|
|
First check for any memory leak in your project-- u can use CMemoryState class for that
If it is ok the check for resource leak.
if it is ok the ckeck all the syncronization objects u r using , is there is any chance of deadlock , it may be possible if u r using timer function fo syncronization object
for locking and unlocking.
CHeck it out ...
I will try for other than these reasons for this
Ashutosh
|
|
|
|
|
Try this article. It has helped me a couple of times.
If you follow it, you will be able to pinpoint the specific line in a specific source file where the program crashed.
In a release build, with minimum overhead.
http://www.codeproject.com/debug/mapfile.asp[^]
|
|
|
|
|
Hi,
I have created a DLL which has certain shared variables/functions. I have accessed the same DLL in another workspace, when I run the application I am facing the following error. Can anone pls. help me out.
Linking...
AccessRegDLLDlg.obj : error LNK2005: _nVar_Subbu already defined in AccessRegDLL.obj
Debug/AccessRegDLL.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
The code in the DLL is:
extern "C" {
__declspec(dllexport) int TestDLLFunction();
__declspec(dllexport) int GetValue();
#pragma data_seg("SHARED")
int nVar_Subbu = 1;
#pragma data_seg()
};
Rgds,
Arun.
|
|
|
|
|
Is this code in the header file? Are you including it from more than one .cpp file?
In a header file, mark the variable as extern (without the initialisation), and declare the variable as normal in a .cpp file.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yes, the code declaring variables and functions to be exported is in the header file of the dll.
I have included it using:
#include "..\RegDLLTest\RegDLLTest.h"
but for using a dll as shared i must initiaize the value in the dll to some value o/w the dll itlself will not compile.
Thanks for your response but i still need help.
It's not working.
---Arun.
|
|
|
|
|
The multiply defined error is occurring because you're defining the variable in your header file and including it in two locations. You need to split the declaration as I said:
Header File:
extern int nVar_Subbu; .cpp File
int nVar_Subbu = 1; Only compile this .cpp file in your DLL.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
try makeing the variable static
static int nVar_Subbu = 1;
nav
|
|
|
|
|
Oh! Thanks Naveen it worked, but can you pls. explain if possible why is static needed.
Rgds,
Arun.
|
|
|
|
|
Hi,
My intention of making the shared dll was that the data or a varibale that is incremented in one exe would reflect in the other. but, making it static the varables have become independent.
Scenario:
I have two exe's accessing the same variable:
i.e "nVar_Subbu" which was initially 1, I have incremented the value of this variable in one exe to 2, when accessed from the other exe it is till showing 1 instead of 2. How to go about this, can anyone help me out pls.
Rgds,
Subbu.
|
|
|
|
|
Why don't u decleare the variable in the CPP file?
nav
|
|
|
|
|
I have used
CProgressCtrl myCtrl;
myCtrl.SendMessage(PBM_SETBARCOLOR,0,RGB(255,0,0));
to change the color of the Progress bar.
But how to change back the color to original.
(If I don't know the color of original)
Please help!
|
|
|
|
|
From the docs:Return Values
Returns the previous progress indicator bar color, or CLR_DEFAULT if the progress indicator bar color is the default color.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
The previous colour is returned by the PBM_SETBARCOLOR message
COLORREF clrPrevious = (COLORREF)myCtrl.SendMessage(PBM_SETBARCOLOR, 0, RGB(255, 0, 0)); Lookup PBM_SETBARCOLOR in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you very much!
myCtrl.SendMessage(PBM_SETBARCOLOR, 0, CLR_DEFAULT);
It is alright now!
|
|
|
|
|
Hai
i am trying to explore a project on creating and destroying threads.in that i am not understanding how to create classes which are MFC based i.e code is written by MFC.The following are classes exists in my application.
1)class CAboutDlg : public CDialog
2)class CChildView : public CWnd
3)class CMainFrame : public CFrameWnd
4)class CThreadsApp : public CWinApp
I am not able to understand how to create these classes.
i confused in which type of project to use to explore this application.
please help me .
Thanks in advance
ravishankar
|
|
|
|
|
ravi1217 wrote: ...i am not understanding how to create classes which are MFC based...
Use ClassWizard.
ravi1217 wrote: I am not able to understand how to create these classes.
They already exist. Why would you want to re-create them?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
To use the class wizard first i need to create a project .
I m in confusion to use which type of project to use.
if i use MFC ApplicationWizard(exe) Single Document class
then i can get these classes as follows.
Document class,viewclass ,MainFrame class and Application class
but where as in my application All classes are MFC based.
and How can then create the following classes using class wizard in my application.
1)class CAboutDlg : public CDialog
2)class CChildView : public CWnd
3)class CMainFrame : public CFrameWnd
4)class CThreadsApp : public CWinApp
ravishankar
|
|
|
|
|
ravi1217 wrote: and How can then create the following classes using class wizard in my application.
1)class CAboutDlg : public CDialog
2)class CChildView : public CWnd
3)class CMainFrame : public CFrameWnd
4)class CThreadsApp : public CWinApp
If you create an SDI application, these classes already exist. You can, however, create other classes derived from CDialog and CWnd using ClassWizard. I'm not sure creating another class from CWinApp would be a good idea since an application only needs/uses one.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|