int x = 0;
cin >> x;
if (x <= 0) return;
//using new (safe for objects)
char* test = newchar[x];
test[0] = 'a';
test[x - 1] = 'b';
...
delete [] test;
//using malloc (not safe for objects)
char* test = (char*) malloc( x * sizeof(char) ); //malloc expects number of bytes
test[0] = 'a';
test[x - 1] = 'b';
...
free( test );
///using calloc (like malloc but zeroes the memory for you)
char* test = (char*) calloc(1, x * sizeof(char) );
test[0] = 'a';
test[x - 1] = 'b';
...
free ( test );
or you could use an object from STL such as a vector or list
1 2 3 4 5 6 7
#include <vector>
std::vector<char> test(x, 0); //initialize to have x values, each being zero (null)
test[0] = 'a';
test[x - 1] = 'b';
//no need to clean up