How to Allocate dynamic memory to string data type...in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to Allocate dynamic memory to string data type...in c++

1st Nov 2019, 5:38 AM
Suraj Pawar
3 Answers
0
Not sure about String but you can always create a character array. char* value = NULL; value = new char[20];
1st Nov 2019, 6:03 AM
Avinesh
Avinesh - avatar
0
How can I know that user gone enter 20 letters only...He can enter more than 20 alos
1st Nov 2019, 6:07 AM
Suraj Pawar
0
You can keep larger values as well, but if the user enters something bigger than that then you have to declare and initialize a whole new memory which can accommodate the content.
1st Nov 2019, 6:25 AM
Avinesh
Avinesh - avatar