c++ - Dynamically increase and decrease char arrays? -
i have send data udp. buffer field of type char. have encrypt/decrypt send. here's code encrypting/decrypting. const unsigned buffer_size = 128; char data[buffer_size]; cout << "enter something." << endl; cin.getline(data, buffer_size); cout << data; char outchar[buffer_size]; for(int = 0; < strlen(data); i++) { //outchar[i] = data[i]; outchar[i] = encr[(int)data[i]]; cout << outchar[i]; } cout << "correct far" << endl; char transchar[buffer_size]; for(int j = 0; j < strlen(outchar); j++) { transchar[j] = decr[(int)outchar[j]]; cout << transchar[j]; // prints out decrypted text , unused space! } the problem here using fixed size of char means there lot of unused space in buffer. in code provided, gets printed screen. is there anyway dynamically increase , decrease buffer (char array) size not unused space? edit: don't think clear: every letter has encrypted , decry...