+ 1
Hi guyss!! Need a bit of help
I have started C++ and doing pretty well{ I mean I think so } and I want to make a calculator. For that I want to declare a variable as a string llike we declare integer if any one of you know this please do tell me.
2 Answers
0
#include <string>
using namespace std;
//can be declared with or without a value
string stringName = "value";
0
In c++, you need to include string library using #include <string> for more features on strings.
After including library you can declare string variable as follows -
string var;
var = "hello";
Above lines will declare string variable var and set its value to "hello". You can do same thing in one line as -
string var = "hello";