Skip to main content
27 events
when toggle format what by license comment
Dec 20, 2023 at 13:06 history edited Jan Schultke
edited tags
Jun 3, 2022 at 6:15 answer added Gabriel Staples timeline score: 0
Oct 27, 2021 at 20:27 answer added SHAH MD IMRAN HOSSAIN timeline score: 2
Jun 17, 2021 at 6:50 answer added Vineeth Peddi timeline score: 0
May 16, 2021 at 11:14 history edited Peter Mortensen CC BY-SA 4.0
Active reading.
Jan 30, 2019 at 2:14 comment added kayleeFrye_onDeck stringName.c_str() so long as it's a std::string, std::wstring, or something like a winrt::hstring.
Feb 17, 2017 at 16:45 answer added anish timeline score: -5
Jan 12, 2016 at 15:53 answer added Pixelchemist timeline score: 24
Oct 6, 2014 at 7:43 history edited Niall CC BY-SA 3.0
Title question
Sep 27, 2014 at 8:38 comment added boycy No, but char* dest = new char[str.length() + 1]; std::copy(str.begin(), str.end(), dest) would be more idiomatic C++. strcpy() and malloc() aren't wrong or problematic, but it seems inconsistent to use a C++ string and C library facilities with C++ equivalents in the same block of code.
Sep 26, 2014 at 0:45 comment added cegprakash @boycy: you mean they are imaginary?
Sep 25, 2014 at 9:29 comment added boycy @cegprakash strcpy and malloc aren't really the C++ way.
Jul 12, 2014 at 12:10 comment added cegprakash char* result = strcpy((char*)malloc(str.length()+1), str.c_str());
Jul 12, 2014 at 12:06 answer added cegprakash timeline score: 8
May 12, 2013 at 8:23 history protected Mat
May 12, 2013 at 8:18 answer added devsaw timeline score: 10
Nov 1, 2012 at 2:03 history edited Luke CC BY-SA 3.0
Formatting code
Oct 5, 2012 at 15:32 comment added paulm You can't use str.size() unless the size is known at compile time, also it might overflow your stack if the fixed size value is huge.
Mar 29, 2011 at 13:32 answer added Alessandro Teruzzi timeline score: 10
Nov 11, 2010 at 9:21 answer added Tony Delroy timeline score: 225
Jun 21, 2010 at 9:34 comment added user372024 Instead of: char * writable = new char[str.size() + 1]; You can use char writable[str.size() + 1]; Then you don't need to worry about deleting writable or exception handling.
Dec 7, 2008 at 19:44 history edited Rob
Tags
Dec 7, 2008 at 19:39 vote accept user37875
Dec 7, 2008 at 19:35 answer added Johannes Schaub - litb timeline score: 1310
Dec 7, 2008 at 19:35 history edited DOK
edited tags
Dec 7, 2008 at 19:31 answer added Mark Ransom timeline score: 40
Dec 7, 2008 at 19:30 history asked user37875 CC BY-SA 2.5