|
AFAIK A memory leak occurs when we don't free a block of memory allocated with the new operator.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
No, not al all if you are actually exiting.
It'll be freed automatically when the program is terminated.
|
|
|
|
|
I want to store current time to a text file. And i want to retrieve that value afterwards and want to compare with the some CTime object. So used CArchieve and failed. Here is my code
<br />
CFile TimeFile;<br />
CTime curTime = CTime::GetCurrentTime();<br />
if(!TimeFile.Open<br />
("TimeFile.txt"<br />
,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite))<br />
{<br />
return;<br />
}<br />
CArchive arTimeFile(&TimeFile, CArchive::store,512);<br />
arTimeFile << curTime;<br />
TimeFile.Close();<br />
I am getting debug error and it shows
void CFile::Write(const void* lpBuf, UINT nCount)<br />
{<br />
ASSERT_VALID(this);<br />
ASSERT(m_hFile != (UINT)hFileNull);<br />
--------<br />
please help me.
KIRAN PINJARLA
|
|
|
|
|
insert line arTimeFile.Flush()after writing data to archive.
your code will be like this,
CFile TimeFile;
CTime curTime = CTime::GetCurrentTime();
if(!TimeFile.Open
("TimeFile.txt"
,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite))
{
return;
}
CArchive arTimeFile(&TimeFile, CArchive::store,512);
arTimeFile << curTime;
arTimeFile.Flush();
TimeFile.Close();
|
|
|
|
|
Thank you prasad. It did work.
Now I need a little more help. I want to read that CTime object from that file and want to compare with another CTime object. I wrote like this
CArchive arTempFile(&TimeFile, CArchive::load);<br />
CTime tempTime;<br />
arTempFile >> tempTime;
</big>
How to do this.
Thank you
KIRAN PINJARLA
|
|
|
|
|
what error its showing ? you need to use flush() this time,too.
I've tested same code here, its not giving any error.
|
|
|
|
|
Prasad. I got it. It is working. It was my fault.I have given a wrong object name.
Thank you somuch for ur help.
GOOD LUCK.
KIRAN PINJARLA
|
|
|
|
|
hi all,
its very basic question but i don't know how to do this in win32,
how to create a binry file .
can i create it with CreateFile.
please let me know.
Thanks and regards
Harshal
|
|
|
|
|
If you are using only win32 (an no MFC), I would suggest that you use FILE (with fopen, fclose, fread, fwrite, ...). To start with it, you can have a look here[^]
If you are using the MFC, then I would suggest that you use the CFile class.
|
|
|
|
|
i am using MFC i tried with CFile::Open
with binary flag but it is not working
so now i will try fopen only because i am not going to
read the data from the file.
i will write and append to it.
|
|
|
|
|
harsha_1234 wrote: with binary flag but it is not working
It should work. If you coul provide more information, maybe we can help. What do you mean by 'it is not working' ? Crash, no file created, compile error, ... Give as much detail as possible.
|
|
|
|
|
|
what do you want to store in it ?
BTW, in C++, prefer STL to C file handling functions (std::fstream )
|
|
|
|
|
CreateFile() do create a binary file.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hi all,
I neeed to read a total of 1500000 bytes via USB.
I need to create a buffer that would receive these USB databytes.
But if I create a buffer to be of more than 60000 bytes wide , I get "stack overflow error".
How do I receive all the bytes/sample points via USB?
Thanks in advance.
|
|
|
|
|
The problem has probably nothing to do with the USB. Post some relevant code so that we can see what you are doing.
|
|
|
|
|
Yes, I think so too.
well,
I use the USB read function FT_Read to read the USB contents which are continuous data of 1500000 bytes.
I need to read them all and hten plot them.
Hence the buffer that is used to read the USB data has to be big enough to receive and store the 15000000bytes in a temp buffer for other operations.
but if the buffer is declared to be rec_buf[Total_num_bytes_to_read]
if the Total_num_bytes_to_read is declared as 64,000 or more the program fails and stays there was an overflow in the stack.
|
|
|
|
|
By declaring rec_buf as a char[] you are putting it onto the stack, which has a limited size. You need to allocate it using the new operator:
char *rec_buf=new char[Total_num_bytes_to_read]
Don't forget to free the memory when you're done with it:
delete [] rec_buf;
|
|
|
|
|
Hi All,
In my project I want to show some statistical data in the graph format. for example the way we can see the line graph in the MS Excel.
In my project I have the x-Axis and Y-axis values stored in to the two dimentional array. I want to show this statastics on the graph in my dialog based application in VC++ 6.0.
can any body please suggest me any free library or code that I can use for the above purpose.
Thanks in Advance.
Dinesh
-- modified at 3:39 Monday 21st August, 2006
|
|
|
|
|
I developped a chart control that does what you are looking for (as far as I can see).
Take a look at the link in my sig for the article about it.
-- modified at 3:51 Monday 21st August, 2006
There are other charting controls here[^] also
|
|
|
|
|
Dear Cédric Moonen,
thanks for the link , I went through the link and guess this is the code I was looking for.
I Will impliment it today in my project
regards,
Dinesh.
|
|
|
|
|
Hi Cédric Moonen,
The code you written is really helpful to me.
will you please tell how to change the color of the graph lines, because When I am applying new colors it is keeping the old color for the line.
Regards,
-DInesh.
|
|
|
|
|
Hi,
I am working with property sheets.My requirement is when I press the first tab(the first property page) all the controls should be in disabled state.This I can do by setting the "disable" property for each and every control.But my requirement is instead of setting the "disable" property for each and every control in every page,I must set the disabled property for all the controls at a time in that page.
To be more specific : suppose if there are 3 tabs.When I press the first tab all the items should be in disabled state.When I press the second tab all the items in that page should be in disabled state and so on.
Hope I am clear.
Thanks in advance.
Sandhya
|
|
|
|
|
Is there any problem using CPropertyPage::OnSetActive ?
|
|
|
|
|
Hi, in my application,when i opened my application i have to enter in tot that by using username.After i closed the application it will create a bacttrack file with the details of user name and timings.For each entry it will write the details in file.And i will show this details in my dialog in ListControl.It reads the details from file and displayed it.Its working fine.But my problem is when the same user entered in to application the file should write all the users.But ListControl shows only the new user.I mean if "A" entered first time and if he enterd second time the ListControl should shows only the updated timings that is last entry only.How can i do this?
Anu
|
|
|
|