?
Solved

_strnset behaving differently while executing in release mode

Posted on 2013-05-30
2
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Subrat (C++ windows/Linux) earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

719 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