I cannot figure out how to assign an integer value to an array of string in C, assuming this is possible of course! I would like to change some elements from a char ** into different values and then re-assign them to their initial position into the array. Practically, I have two element, "Mon" and "Aug", which I would like to become "01" and "08"... So I tried something but unsuccessfully:
char *time_array[7] = {"45", "55", "11", "Mon", "29", "Aug", "2022"};
uint32_t day2convert = 1;
uint32_t month2convert = 8;
*time_array[3] = &day2convert; // not even with a cast (char) which gave same results
*time_array[5] = &month2convert;
for (j = 0; j < 7; ++j)
printf("after conversion : %s\n", time_array[j]);
/*
Results for the two elements are different at each main call, as I'm randomly picking values present in different memory allocations (maybe). Es. don, hug; 4on 8ug, ton xug... Moreover i tried also with strcpy function as:
strcpy(time_array[3], &day2convert); //also with a cast (char)(&day2convert)
but still I retrieve a void string.
So, gently, I'm asking if there could be a way to do what I want in principle, but also asking for some explanations about array of string. Because what I learnt is that a char ** is an array of pointer so it should be right to assign a value to it as *array[ii] = &var (??? in search of confirmation)