a little help with array to string
Hi, I'm trying to make a function that will extract a range of elements from an array and make a string out of them...program keeps crashing after exacution.... any suggestions?
Code:
#include <fstream.h>
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
char * gav (char * arg[], int start, int end) {
char * z;
char * x;
z = new char;
x = new char;
while (start < end) {
z = arg[start-1];
strcat (z,x);
start++;
}
return x;
}
int main ()
{
char * mostunleetarray[] = {"workyou"};
char * value;
value = gav (mostunleetarray,1,4);
cout << value << "\n";
system ("PAUSE");
return 0;
}