I am exploring to add an element, ASCII letters to my random generated 1D array to form new array. How can I use <cstring> header to achieve my result.
#include <iostream>
#include <ctime>
#include <cstring>
#include <cstdlib>
using namespace std;
const int MAX = 10;
void constructSet1 (char*, int);
int main ()
{
char x[MAX];
char* a = x;
srand (time(NULL));
cout << "Element A: ";
constructSet1 (a, 10);
cout << endl;
cout << "Enter a ASCII letter: ";
//cin <<
cout << endl;
cout << "Final Array: ";
}
//Construct Element A
void constructSet1 (char* a, int size)
{
//Get random size of 2 - 10
size = rand () % 9 + 2;
cout << "{";
for (int i = 0; i < size; i++)
{
a[i] = static_cast <char> (rand () % 26 + 65);
cout << a [i];
if (i < size - 1)
cout << ",";
}
cout << "}";
}
void insertElement ()
{
}