Solved

_strnset behaving differently while executing in release mode

Posted on 2013-05-30
2
190 Views
Last Modified: 2013-10-23
Hello Experts

Following is the code which appends spaces to a CString.
		long l_no_of_chars = 100;
		LPSTR t_space_text = NULL;
		CString u_space;

		//	Allocate that much space
		t_space_text = (LPSTR) malloc (l_no_of_chars + 1);
		//	Fill the variable with 32
		_strnset( t_space_text, 32, l_no_of_chars);	
		//	Set the Last Character
		*(t_space_text + l_no_of_chars) = 0;
		//	Get the Left Text
		u_space = t_space_text;
		::MessageBox (NULL,"File", u_space, MB_OK | MB_ICONINFORMATION);

		//	Free allocated memory
		free (t_space_text);

Open in new window

When I excute in release mode MessageBox is not displaying spaces  and when I debug in the release mode it is showing.

Please help in getting resolved, Thanks in advance.
0
Comment
Question by:HarishMinu
2 Comments
 
LVL 8

Accepted Solution

by:
Subrat (C++ windows/Linux) earned 500 total points
ID: 39212345
Try using safer version _strnset_s instead of _strnset(Deprecated One).
I hope in release ver. due to code optimization, it might be truncating spaces...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now