c++ - Dynamically change size of char variable -


i want use string or char variable size can change dynamically. don't need specify size , in code can add cell , insert new char cell. use code action:
char *align_a = (char*)malloc(lenmax*sizeof(char));
there way don't need specify size (in here lenmax) , when want add new char array or memory, dynamically add cell , insert char character into. can use string action?
for example: first add aligna, a character, next character b size of memory or array changed , add b , ...

since use c++ , not c, use std::string or std::vector, they'll make life lot easier, designed tasks describe.

if want stick char *, check c-style realloc function.


Comments