I'm trying to split an array which is that of unsigned char where NULL marks the split point
I have written this code, but it just looks clunky, and I would like to ask advice on any other
more efficient methods of doing such a thing there might be.
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdio.h>
#define mymaxarray 256
typedef unsigned char uchar;
using namespace std;
void testFunc00(uchar *, int, uchar **);
int _tmain(int argc, _TCHAR* argv[])
{
char c;
uchar a1[mymaxarray] = {0};
uchar a2[mymaxarray] = {0};
uchar a3[mymaxarray] = {0};
uchar a4[mymaxarray] = {0};
uchar * arrayofarray[4] = {a1,a2,a3,a4};
uchar testarray[30] = {'1','1','1','\0','1','1','1','1','1','1','1','\0','1','1','1','1','1','1','1','1','1','1','1','1','1','\0','1','1','1','\0'};
testFunc00(testarray, 30, arrayofarray);
int x = 0;
while (a1[x]) {
cout << a1[x] << endl;
x++;
}
cout << endl;
x = 0;
while (a2[x]) {
cout << a2[x] << endl;
x++;
}
cout << endl;
x = 0;
while (a3[x]) {
cout << a3[x] << endl;
x++;
}
cout << endl;
x = 0;
while (a4[x]) {
cout << a4[x] << endl;
x++;
}
cin >> c;
return 0;
}
void testFunc00(uchar * in, int len, uchar ** out){
int i = 0;
int n = 0;
while (in[i]) {
out[0][n] = in[i];
i++;
n++;
}
i++;
n = 0;
while (in[i]) {
out[1][n] = in[i];
i++;
n++;
}
i++;
n = 0;
while (in[i]) {
out[2][n] = in[i];
i++;
n++;
}
i++;
n = 0;
while (in[i]) {
out[3][n] = in[i];
i++;
n++;
}
}
Sorry if code is unformatted, cannot seem to preview.