Related
kelemat I know it's safe... const char *get_str_literal() {
return "I literally can't even";
}
But is it? const char *get_str_literal() {
const char *str = "I literally can't even";
return str;
}
If not, why? EDIT : How does the following differ
kelemat I know it's safe... const char *get_str_literal() {
return "I literally can't even";
}
But is it? const char *get_str_literal() {
const char *str = "I literally can't even";
return str;
}
If not, why? EDIT : How does the following differ
kelemat I know it's safe... const char *get_str_literal() {
return "I literally can't even";
}
But is it? const char *get_str_literal() {
const char *str = "I literally can't even";
return str;
}
If not, why? EDIT : How does the following differ
kelemat I know it's safe... const char *get_str_literal() {
return "I literally can't even";
}
But is it? const char *get_str_literal() {
const char *str = "I literally can't even";
return str;
}
If not, why? EDIT : How does the following differ
Bernard Typically, I would return a std::stringfrom a function , because returning a const char*would require the caller to provide an output memory buffer, which is not resizable. But const char*does it work if it is returned from a string literal ? const cha
Bernard Typically, I would return a std::stringfrom a function because returning a const char*would require the caller to provide an output memory buffer, which is not resizable. But const char*does it work if it is returned from a string literal ? const char*
Bernard Typically, I would return a std::stringfrom a function because returning a const char*would require the caller to provide an output memory buffer, which is not resizable. But const char*does it work if it is returned from a string literal ? const char*
scab I'm looking at the following code (simplified) and asking myself how returnMsgsafe it is to use this: #include <iostream>
using namespace std;
const char *returnMsg(const char *msg)
{
static std::string message;
message = msg;
return messa
scab I'm looking at the following code (simplified) and asking myself how returnMsgsafe it is to use this: #include <iostream>
using namespace std;
const char *returnMsg(const char *msg)
{
static std::string message;
message = msg;
return messa
scab I'm looking at the following code (simplified) and asking myself how returnMsgsafe it is to use this: #include <iostream>
using namespace std;
const char *returnMsg(const char *msg)
{
static std::string message;
message = msg;
return messa
scab I'm looking at the following code (simplified) and asking myself how returnMsgsafe it is to use this: #include <iostream>
using namespace std;
const char *returnMsg(const char *msg)
{
static std::string message;
message = msg;
return messa
scab I'm looking at the following code (simplified) and asking myself how returnMsgsafe it is to use this: #include <iostream>
using namespace std;
const char *returnMsg(const char *msg)
{
static std::string message;
message = msg;
return messa
User 4054130 I have a function I want to use, const char*but it only works with string literals because they are given special rules to allow array initialization. The second overload is preferred foo(const char*)for both string literals and const char*s , but
User 4054130 I have a function I want to use, const char*but it only works with string literals because they are given special rules to allow array initialization. The second overload is preferred foo(const char*)for both string literals and const char*s , but
Daniel I need a function to return a string based on a code value and a helper value, I think the sample code shows what I'm trying to do, and there might be an easy way to do this, but I'm stuck. There's going to be a lot of code numbers and this is the best
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Triskeldeian I have a relatively simple use case: I want to associate a trait with a class that will return some user-defined string, i.e. some user-defined registration ID. Since this registration should be defined at compile time, I wanted it to be constexpr
Colin Hicks I need help understanding some code. I read elsewhere that it is legal to pass a string literal as a . However, in the last line of this code in cppreference for user-defined string literals , it says there is no literal operator . Why is this happ
Colin Hicks I need help understanding some code. I read elsewhere that it is legal to pass a string literal as a . However, in the last line of this code in cppreference for user-defined string literals , it says there is no literal operator . Why is this happ
new bee I found the following code in libcurl : const char *
curl_easy_strerror(CURLcode error)
{
switch(error) {
case CURLE_OK:
return "No error";
case CURLE_UNSUPPORTED_PROTOCOL:
return "Unsupported protocol";
.....
}
As far as I know, if you
new bee I found the following code in libcurl : const char *
curl_easy_strerror(CURLcode error)
{
switch(error) {
case CURLE_OK:
return "No error";
case CURLE_UNSUPPORTED_PROTOCOL:
return "Unsupported protocol";
.....
}
As far as I know, if you
Black Temple I have written a custom print function. My problem is that I need to return a const char*because it has to be used in another function . I don't know how to manage it at all... anotherFunction (const char* text /*Here*/, unsigned __int32 value, un
David Galbraith I got this working to return an integer: CREATE FUNCTION my_function() RETURNS INTEGER AS $$
SELECT 1 AS result;
$$ LANGUAGE SQL;
But I wanted it to return a string, so I adjusted it to: CREATE FUNCTION my_function() RETURNS TEXT AS $$
SEL
Manas Swain I'm really struggling to figure out how to return strings from one function to another. Please help me to solve this problem. Return the password as a string from this function: char* password(void) {
const maxPassword = 15;
char password[maxPa