473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Intended behavior or bug -- VC 2005 Beta 2

#include <string>
using namespace std;

{
const string s("George");
char* p = const_cast<char*>(s.c_str());
strcpy_s(p, s.length(), "John");
}

Thanks.

George
Nov 17 '05 #1
2 783
George Poulose wrote:
#include <string>
using namespace std;

{
const string s("George");
char* p = const_cast<char*>(s.c_str());
strcpy_s(p, s.length(), "John");
}


The const_cast invokes undefined behaviour. What were you expecting and how
is it different from what you sought? As a reminder, it is legal for
std::string to have embedded "\0" characters, but of course display of such
a string may be problematic.

Arnaud
MVP - VC
Nov 17 '05 #2

"George Poulose" <gpoulose[*AT]att.net> skrev i meddelandet
news:OQ**************@TK2MSFTNGP10.phx.gbl...
#include <string>
using namespace std;

{
const string s("George");
char* p = const_cast<char*>(s.c_str());
This cast isn't allowed by the language. That makes the program
invalid.
strcpy_s(p, s.length(), "John");
}

Thanks.

George


Bo Persson
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bill Mill | last post by:
On my laptop, I have an NTFS partition for NT, a FAT partition for data as a dmz which both linux and NT can access, and an ext3 partition for linux. However, I've experienced some weirdness on the...
48
by: ik | last post by:
ERROR after uninstalling SQL Server 2005 Express I get this message, SQLDMO has not been registered. Please re-run your setupand contact your system administrator. GREAT!!! ReInstalled SQL...
10
by: aka | last post by:
// classA.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; static unsigned int count = 0;
8
by: Rusty Shackleford | last post by:
Is it normal behavior for the aspnet_wp.exe process to exit immediately after starting? This is happening to me without any errors in the application event log. No matter what ASP.Net application...
1
by: cryogeneric | last post by:
Hello everybody, I'm not all that familiar with backing up and restoring databases on SQL 2005 and I have a question. First, let me give you a little insight into how we're setup and what we want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.