+ 3
How do I return a string from a function? (C++)
Hi! I want to have a string as a return of my function, but I don't know if it is actually possible. If yes, how can I do it? đ
7 Answers
+ 8
here's how you can do:
https://code.sololearn.com/c6Ld294nqZI9/?ref=app
+ 6
char* func(char* s) {
Char* string = s;
return string;
} // there is no string type in C
+ 3
string function(){
string s = "How to";
return s;
}
+ 3
Sure.
string test() {
return "test";
}
int main() {
cout << test();
}
+ 2
c != c++
+ 1
Oh okay it's just this, thank you! đ đ
+ 1
Thatâs what I though also but it worked on sololearn so