0
How can i return a string?
Can someone tell me how to return a string (not like "Hello world",like the name of the string) in a function? (In C++ Btw)
3 Antworten
+ 1
Use string type:
#include <iostream>
#include <string>
using namespace std;
string getString()
{
string s = "some string";
s += " result";
return s;
}
int main() {
cout << getString() << endl;
}
+ 1
What exactly do you mean?
0
Do you mean the name of the string variable?