|
how can i save the time or the serial no of the hard in text file using C++...
plz help me...
bishoy
|
|
|
|
|
|
I see three separate issues here: 1) time; 2) HDD serial number; 3) file I/O. Which are you having troubles with?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
BishoyShoukry wrote: time
CTime::GetCurrentTime()
BishoyShoukry wrote: serial no of the hard
GetVolumeInformation()
BishoyShoukry wrote: text file using C++..
CStdioFile
"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
|
|
|
|
|
Hi
thsi is my code:
<br />
#include <cstdlib><br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
class C{<br />
private :<br />
int i ;<br />
char * ch;<br />
<br />
public :<br />
C();<br />
C(int,char *);<br />
~C();<br />
};<br />
C::C(int a,char * d)<br />
{<br />
cout << "initializing";<br />
i = a;<br />
ch = new char[strlen(d)+1];<br />
strcpy(ch, d);<br />
<br />
<br />
}<br />
C::C()<br />
{<br />
cout << "default";<br />
}<br />
C::~C()<br />
{<br />
cout << "deleting";<br />
delete[] ch;<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
C c;<br />
C * c1 = new C(10,"string");<br />
delete c1;<br />
<br />
return 0;<br />
}<br />
this code when i start debugging ,it compiled then start executing when closing it gives(in VS2005):
"Windows has triggered a breakpoint in sdf.exe.
This may be due to a corruption of the heap, and indicates a bug in sdf.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information"
Why do i get this error in VS 2005 but not in dev c++.What is wrong?I can not the solve the problem in my code or in my debugger or something else..
Thanks...
-- modified at 7:42 Friday 12th May, 2006
|
|
|
|
|
In your main you declare C c; . This will call the default constructor of C which does nothing. When you leave the main function, the destructor of C will be called and this does:
C::~C()
{
cout << "deleting";
delete[] ch;
}
And ch is not initialized thus you try to free memory that has not been allocated. Always always intialize your member variables in your constructors !!!!
C::C()
{
cout << "default";
i = 0;
ch = NULL;
}
(in your destrutor, you can check the validity of your pointer with if(ch) but this is not required because it is safe to delete a NULL pointer, this will simply do nothing).
Cédric Moonen
Software developper
Charting control
|
|
|
|
|
ok.I understand.
thank you friend.
Good works...
|
|
|
|
|
And a lesson learned (and demonstrated) - just because something compiles, links, executes and works, that does not necessairly mean that it is correct.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Especially when something behind the scenes is helping out, as seems to be the case here.
Software Zen: delete this;
|
|
|
|
|
Hi,
how to start a word apllication from our application and then write Formatted text in word application. Where are functioins for these available.
|
|
|
|
|
Better if you search for key words like Automating Word.
You can find some articles for the same.
One of them is :
http://support.microsoft.com/?kbid=237337[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi All,
How we can get drawing notification for scrollbar in a Listbox control
Regards,
Sarath
Currently I am working as software engineer at Network System Technologies Pvt. Ltd (NeST). Most of my project are in C++. Most interesting are is GUI programming.
|
|
|
|
|
Sarath C wrote: How we can get drawing notification for scrollbar in a Listbox control
u can't ..
only way is to hook the scrollbar API's. This can be done easly using the Detours
check this sample
http://www.codeproject.com/dialog/coolscroll.asp[^]
nave
|
|
|
|
|
Hi, I got Unhandled Exception in my coding,and i debugged through my coding,the unhandled exception came in disassembly section.Why its come in disassembly ?Wats the reason?
-- modified at 6:45 Friday 12th May, 2006
|
|
|
|
|
Anu_Bala wrote: Why its come in disassembly ?
because it doesn't have the source to debug in...
Anu_Bala wrote: I got Unhandled Exception in my coding,
great. which ?!
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Tell what type of error ?? & where it got generated ??
while posting try to give more details abt the req so u get good solutions.
|
|
|
|
|
|
Hi,I am asking generally..Just i do some file reading and adding to list.Thats all.The error is UnHandled Exception in MFC42d.dll.The error occurred after it returns from the InitInstance().After it returns,it goes to disassembly and then show this error.The line on which it shows is (5F42AF82 cmp dword ptr [eax],0)
|
|
|
|
|
im not sure maybe your problem is read files.
|
|
|
|
|
Why ? It can be anything. Very often, this is due to memory violation (you try to read or write were you are not allowed to).
Cédric Moonen
Software developper
Charting control
|
|
|
|
|
i dont say that problem is file i say maybe.
if you want to add items to listbox do you get error
if he use listbox
-- modified at 7:28 Friday 12th May, 2006
it worked
m_List.Create(WS_VSCROLL|WS_BORDER|WS_HSCROLL|WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),this,1);
WIN32_FIND_DATA find;
HANDLE handle;
handle=FindFirstFile("*.*",&find);
for(int i=0;i<10;i++)
{
m_List.AddString(find.cFileName);
if(!FindNextFile(handle,&find))
break;
}
FindClose(handle);
|
|
|
|
|
Correct me if I'm wrong, but you can't initialize a listbox in InitInstance.
Try doing it in OnInitDialog instead.
|
|
|
|
|
vinaycool wrote: while posting try to give more details abt the req so u get good solutions.
please try not use SMS language here, hope i am not sounding like any bore lecturer
"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
|
|
|
|
|
i second you Alok, i DO am bored about that too, because i make efforts to speak an english that everyone can understand (while english is not my mother tongue), and these guys come with the sms-ed language and want, want, want the worst thing is that i'm sure they don't behave like that in real life
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Start your debugger (press F5) and set breakpoints in your prog to see where it crashes. You can also use the Callstack window to see which was the last of your functions called (and probably giving you the error).
Cédric Moonen
Software developper
Charting control
|
|
|
|