I have the following part of the code:
i = 0;
while (ptr != NULL)
{
if (i == 0)
strcat(machine, ptr);
if (i == 2)
strcat(number, ptr);
if (i == 4)
strcat(hr, ptr);
if (i == 6)
strcat(dw, ptr);
if (i == 8)
strcat(vcc, ptr);
i++;
}
printf("Final: %s, %s, %s, %s, %s\n", machine, number, hr, dw, vcc);
And i have these results:
Final: 3, 34, 56, 67, 56
How can I save them in a 10 position array in the positions 5-9? To be like that:
0 0 0 0 0 3 34 56 67 56
I wrote the following code but it is uncompleted because I do not know how to pass &machine, &number, &hr, &dw, &vcc in the table
FILE *ft = fopen("Desktop/mytext.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 table1[1][10];
for(int i = 0; i<1; i++)
{
fprintf(ft,"%s ",s);
for(int j = 0; j<10; j++)
fprintf(ft,"%d ",table1[i][j]);
}