I am asking the user to input a string on console. But I don't know the length of string.
How can I define a structure to fit the input with variable length?
int main(){
    int i;
    char s[10];
    cout << "input string:";
    cin >> s;
    return 0;
}
The sample code will cause heap corruption if the input string length exceeds 10.
 
     
     
     
     
     
     
    