Click here to Skip to main content
15,909,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerYes Pin
CPallini30-May-07 22:19
mveCPallini30-May-07 22:19 
GeneralMore reference Pin
C_Zealot30-May-07 22:24
C_Zealot30-May-07 22:24 
GeneralRe: More reference Pin
CPallini30-May-07 22:27
mveCPallini30-May-07 22:27 
GeneralRe: More reference Pin
toxcct30-May-07 23:45
toxcct30-May-07 23:45 
Questionattach a doc Pin
p_30-May-07 22:10
p_30-May-07 22:10 
AnswerRe: attach a doc Pin
_AnsHUMAN_ 30-May-07 22:32
_AnsHUMAN_ 30-May-07 22:32 
QuestionRe: attach a doc Pin
David Crow31-May-07 4:58
David Crow31-May-07 4:58 
QuestionIs this called Buffre overrun Pin
vipin_nvk30-May-07 21:40
vipin_nvk30-May-07 21:40 
Hello

I have a strange problem in my code. I call this function to return me the current date and time. But, what I have observed is that once this piece of code gets exceuted in my workspace, all the CString variables in the workspace get initialized with the current date time by default (though they have been intialized with empty strings)

Is this because of the concept called buffer overrun. Is there anything like buffer overrun happening here where in the memory is getting corrupted because we are not specifying the size of the source / target buffers into which the strings have to be copied.

Please do clarify. Find the code snippet attached.

<br />
CString CLogger::GetCurrentDateTime()<br />
{<br />
	CString strCurrDateTime,strTemp;<br />
<br />
	SYSTEMTIME stCurrent,stLocal;<br />
	GetSystemTime(&stCurrent); <br />
	SystemTimeToTzSpecificLocalTime(NULL, &stCurrent, &stLocal);<br />
<br />
<br />
	wsprintf(strCurrDateTime.GetBuffer(0),_T("%02d/%02d/%d  %02d:%02d"),stLocal.wDay, stLocal.wMonth, stLocal.wYear,stLocal.wHour, stLocal.wMinute);<br />
<br />
	return strCurrDateTime;<br />
}<br />


Regards,
Vipin.
AnswerRe: Is this called Buffre overrun Pin
Cedric Moonen30-May-07 21:52
Cedric Moonen30-May-07 21:52 
AnswerRe: Is this called Buffre overrun Pin
Optimus Chaos30-May-07 22:01
Optimus Chaos30-May-07 22:01 
AnswerRe: Is this called Buffre overrun Pin
CPallini30-May-07 22:02
mveCPallini30-May-07 22:02 
AnswerRe: Is this called Buffre overrun Pin
Matthew Faithfull30-May-07 22:46
Matthew Faithfull30-May-07 22:46 
QuestionCListCtrl Pin
Steve14430-May-07 21:27
Steve14430-May-07 21:27 
AnswerRe: CListCtrl Pin
Naveen30-May-07 22:09
Naveen30-May-07 22:09 
GeneralRe: CListCtrl Pin
Steve14431-May-07 12:45
Steve14431-May-07 12:45 
GeneralRe: CListCtrl Pin
Naveen31-May-07 13:58
Naveen31-May-07 13:58 
GeneralRe: CListCtrl Pin
Steve14431-May-07 14:23
Steve14431-May-07 14:23 
GeneralRe: CListCtrl Pin
Naveen31-May-07 14:27
Naveen31-May-07 14:27 
GeneralRe: CListCtrl Pin
Steve14431-May-07 14:35
Steve14431-May-07 14:35 
QuestionBluetooth programming problem Pin
followait30-May-07 21:23
followait30-May-07 21:23 
AnswerRe: Bluetooth programming problem Pin
Roger Stoltz30-May-07 22:08
Roger Stoltz30-May-07 22:08 
QuestionCDlg on active (MFC) Pin
waxie30-May-07 21:21
waxie30-May-07 21:21 
AnswerRe: CDlg on active (MFC) Pin
Roger Stoltz30-May-07 21:53
Roger Stoltz30-May-07 21:53 
GeneralRe: CDlg on active (MFC) Pin
waxie30-May-07 21:58
waxie30-May-07 21:58 
GeneralRe: CDlg on active (MFC) Pin
Roger Stoltz30-May-07 22:02
Roger Stoltz30-May-07 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.