Basically, I want my function stringFeatures to output the size and capacity of variables text
, text1
and text2
. I'm trying to assign text
, text1
and text2
separately to the variable to make the code less confusing but I haven't had any success. How would I go about this? Thank you
#include <iostream>
#include <string>
using namespace std;
int main() {
string text = "Banana";
string text1 = "Orange";
string text2 = "Grapes";
string variable = text + text1 + text2;
void stringFeatures (string variable);
{
cout << "Size: " << variable.size();
cout << "Capacity: " << variable.capacity();
}
cout << variable << endl;
}
I expect the output to be the size and capacity of each string separately but I don't know how to assign each variable separately, I've just combined all my variables altogether instead as shown in the string variable
because I don't know what to do