Hello All I have a problem where my char arrays (strings)
won't display anything past 318 characters
. If I do a std::string
it's fine and displays the whole thing... but if I try to convert it to a char array using std::string.c_str()
it only produces the first 318 characters
again. Any help would be greatly appreciated. I'm using Visual Studio 2017
. The actual string length is 517chars
.
Example...
std::string x = "INSERT INTO oms.Customers (customerFirstName, CustomerMiddleInitial, customerLastName, customerPrefixSuffix, customerCompanyName, customerStreetReference, customerStreetAddress, customerCity, customerState, customerZip, CountryID, customerPhoneNumber, customerEmail, customerIsCompany, customerIsActive) Values('Bill', '
INSERT INTO oms.Customers(customerFirstName, CustomerMiddleInitial, customerLastName, customerPrefixSuffix, customerCompanyName, customerStreetReference, customerStreetAddress, customerCity, customerState, customerZip, CountryID, customerPhoneNumber, customerEmail, customerIsCompany, customerIsActive)Values('Bill', ' ', 'Cosby', '', 'The Cosby Show', 'Studio A', '1818 broadway st', 'Philadelphia', 'PA', '19809', '', '6169875942', 'Bill.Cosby@ididntdoit.com', '', ');SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY];"
but if I make any type of char array such as if I did
char *y;
y= x.c_str
only the below will show
INSERT INTO oms.Customers (customerFirstName, CustomerMiddleInitial, customerLastName, customerPrefixSuffix, customerCompanyName, customerStreetReference, customerStreetAddress, customerCity, customerState, customerZip, CountryID, customerPhoneNumber, customerEmail, customerIsCompany, customerIsActive) Values('Bill', '
if I do strlen(y)
I get 318
. If I do x.length()
I get 517
.
Any help would be greatly appreciated. Thank You.
std::string
may contain '\0'
characters, which will be identified as C-style NUL
terminated string end markers by strlen(y)
.
That's why the results are different for strlen()
and std::string::length()
.