I don't want to declare character array. I want to declare string. And take input and show output of that string using scanf and printf. I have tried to do it this way that's shown below but it doesn't work properly. How to do it in proper way?
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
scanf("%s", str.c_str());
printf("%s", str.c_str());
return 0;
}