If I have 5 arrays of char like this
char a[6] = "";
char b[6] = "";
char c[6] = "";
char d[6] = "";
char e[6] = "";
and I also have this part of code which gets some tokens with strtok and put them in a,b,c,d,e
while(fgets(buff, sizeof(buff), fp) != NULL)
{
fputs(buff,stdout);
FILE *ft = fopen("/home/pi/Desktop/data.txt","a+");
struct tm *tp;
time_t t;
char s[80];
t = time(NULL);
tp = localtime(&t);
strftime(s, 80, "%d/%m/%Y %H:%M:%S", tp);
char *pos = strchr(buff,'N');
if (pos)
{
ptr = strtok(buff, "Nodo_,=:V()");
i = 0;
while (ptr != NULL)
{
if (i == 0)
strcat(a, ptr);
if (i == 2)
strcat(b, ptr);
if (i == 4)
strcat(c, ptr);
if (i == 6)
strcat(d, ptr);
if (i == 8)
strcat(e, ptr);
ptr = strtok(NULL, "Nodo_,=:V()");
i++;
}
printf("Results: %s, %s, %s, %s, %s\n", a, b, c, d, e);
my question is how can I create a new array (example TABLE) with these 5 values like
a
b
c
d
e
and secondly is there any way to convert this array to
a b c d e