0
Can anyone tell me how to input a string by user and store it in a variable?
please someone tell me (cpp) i want to input a string by user and store in string type variable, can i do?
2 odpowiedzi
+ 3
#include <iostream>
using namespace std;
int main() {
//declaring string type variable
string str;
//taking input by user
getline(cin,str);
//printing inputted string
cout<<"your string: "<<str;
return 0;
}
+ 1
Rupali thanks a lot dear🙏🙏