|
i use the following code
int a = 10;
char ch [2];
CString str;
itoa (a, ch, 10);
str += ch;
i get the warning of deprecated, hence i use
int a = 10;
char ch [2];
CString str;
_itoa(a, ch, 10);
str += ch;
i again get deprecated warning, now i use
int a = 10;
char ch [2];
CString str;
_itoa_s (a, ch, 2, 10);
str += ch;
this time when the above line, i.e _itoa_s (a, ch, 10); is executed i get Assertion error !!
|
|
|
|
|
kapardhi wrote: i get the warning of deprecated, hence i use
int a = 10;
char ch [2];
CString str;
_itoa(a, ch, 10);
str += ch;
It is still using the deprecated version of the function.
kapardhi wrote: int a = 10;
char ch [2];
CString str;
_itoa_s (a, ch, 2, 10);
str += ch;
this time when the above line, i.e _itoa_s (a, ch, 10); is executed i get Assertion error !!
Your buffer is too small: it should contain two characters plus the null-terminating zero of the string. So, it should be 3 instead of 2.
|
|
|
|
|
kapardhi wrote: How to get rid of these warnings?
See here.
kapardhi wrote:
i tried with _sitoa_s, but when this line gets executed it gives assertion error !!
What line of what file asserted?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hai all,
I select a file in my program(from a dialog), after closing the present dialog if i open another dialog and select the same file it is throughing error (m_hFile != INVALID_HANDLE_VALUE). Please any one help me.
Thanks and Regards
Bhanu
|
|
|
|
|
Did you try debugging to see what is happening exactly ?
|
|
|
|
|
is the file still open? (thats what the Assertation screemed)
did you CFile::Close();
Greetings from Germany
|
|
|
|
|
It seems you must be close previous handle of fiel.
|
|
|
|
|
lets have a registry of following type:
HKLM -> Software -> LAv -> p = 0
HKLM -> Software -> LAv ->name1 = "xyz"
HKLM -> Software -> BDD -> q = 1
HKLM -> Software -> BDD -> str = "stu"
now i want to search for key 'q' from HKLM/sofware.
is it possible? if yes plz help me with your ideas.
thanks !
modified on Monday, September 29, 2008 5:44 AM
|
|
|
|
|
RegEnumKeyEx[^]
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
i need to write a code which will show which kind of network adapter it's.taht means whether its ethernet or wireless or something else.I tried using GetAdapterInfo but foe "wireless adapter" its also showing "ethernet".Can anybody suggest any other API.I don't want WMI.Thanks.........
|
|
|
|
|
|
no,i didn't find anything useful for me in your article.Thanks anyway...
|
|
|
|
|
Hey all,
I got a little problem, I'm using VS2008 and built a console MFC app all was well, it works and does excactly what I need but....
I was testing the application on a clean Windows XP SP3 with IE7. But the application failed to run, I realised this was due to the common runtime, since VC9 runtimes are not installed on the test PC. We do not want to have to install the runtimes, so I rebuilt the exe with /clr but all I get is 0xc000135 when I try to run it, I have tried various methods to get round this. The only way I can get it to work is to have the MFC and CLR dlls in the same folder using private assemblies in the manifest.
I want to avoid this, if possible? anyone help?
Thanks in advance!
|
|
|
|
|
/clr is for enabling using managed code from C++ and has got nothing to do with your problem. As far as I know there ase only 3 says to ship the CRT and MFC DLL's.
1. Install VC++ redistributable package on client machine.
2. Statically link to both CRT and MFC libraries.
3. Install CRT and MFC DLL's as private assembly.
Static linking typically create problems if the executable depends on other 3rd party DLL's which use dynamic version of CRT or MFC.
For the private assembly follow in instruction at http://www.codeproject.com/KB/cpp/vcredists_x86.aspx[^], there is a section on "Install a private assembly".
-Saurabh
|
|
|
|
|
Ah I thought /clr was for CRT...my noobish mistake
Thanks for the help I'll linking CRT along with my already Static linked MFC
|
|
|
|
|
Got it working!! yeah!!
Thanks for your help!
I have origonally started with a shared MFC link and wanted to change it, I tried looking at /MT before but the compiler complained so I thought I was doing something wrong.
In the end it was all because I started the project as a shared MFC link and used the _AFKDLL preprocessor defination. Removing _AFXDLL and chaning to a Static MFC link and using /MT the exe compiled and works now.
Well atleast I learned more about the IDE and how things are compiled and linked.
|
|
|
|
|
Did you try linking to the MFC Dll's statically, but this would increase the size of your application considerably.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi, Is there any memory leak in the below code... if there are how can resoleve it.thaks..
class test<br />
{<br />
int a;<br />
public:<br />
test(int i):a(i){}<br />
void diplay(test* tst)<br />
{<br />
int i = tst->a+30;<br />
cout<<i<<endl;<br />
}<br />
~test(){}<br />
};<br />
<br />
int main()<br />
{<br />
<br />
<br />
test* test1;<br />
test1->(new test(20));
<br />
return 0;<br />
}<br />
|
|
|
|
|
I've never seen something written like test1->(new test(20)); //debugger telling me here is memory leak. before... what do you expect this line to do???
|
|
|
|
|
sorry..Small typo error..it suppose to be test1->display(new test(30)).It will create pointer to that object while passing as a argument. It may be reducing lines of codes. But my question is is it good practice?
modified on Monday, September 29, 2008 3:39 AM
|
|
|
|
|
well in that case you definitely do have a memory leak, as you are allocating memory with new , but you never called delete on it, and have no way to, because it was never assigned to a variable, but instead simply passed directly into a function.
What you should do is allocate memory to a variable using new first, and then pass that variable to the function, like so;
test * theVar = NULL;
theVar = new test(30);
test1->display(theVar);
Then when you are done with theVar call delete on it and assign NULL to it;
delete theVar;
theVar = NULL;
And then you have no memory leak.
Another thing to keep in mind is to check whether or not theVar is NULL before you use it, so back in my original code snippet you would change it to something like this;
test * theVar = NULL;
theVar = new test(30);
if(theVar != NULL)
{
test1->display(theVar);
}
else
{
}
|
|
|
|
|
|
it is a litle crappy.
better:
test1 = new test(20);
//at end
delete test1;
Greetings from Germany
|
|
|
|
|
SRKSHOME wrote: test1->(new test(20));
That is because you are doing memory allocation with new, and you have no way of deleting the pointer to that memory location, since you don't have a variable to delete. Try using a pointer variable and then you can free the memory it points to
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
There are two bugs in this program:
1. test1->(new test(20)); // This is incorrect. Perhaps you mean test1->display(new test(20));
2. You are using test1 without allocating memory for it.
You can try something like this:
test* test1 = new test;
test* test2 = new test;
test1->display(test2);
delete test1;
delete test2;
Or
test test1;<br />
test test2;<br />
test1.display(&test2);
-Saurabh
|
|
|
|