beginner – Extract and reformat text dates

When you declare a function that you only expect to use in the current file, mark it static.

The user (anonymous) in the previous comments is correct to indicate that accumulate it's pretty big; However, instead of assigning it statically as a whole, I would suggest that it be assigned from the heap (malloc).

printf ("% s n", dates) It is equivalent to put (dates), but the latter is more efficient.

Having to predetermine the variables in C has not been necessary since the 90s. It does not predetermine the variables. Declare them where they are used; that is to say

for (int i = 0;

That loop does not do what you think it does. You lack keys. The loop will only apply to the first Yes.

j + = 8

Where does 8 comes from? Declare this as a constant. The magic numbers are bad.

It is useless to have a return value for pickDates, then do it empty.

date_str in isDate It should be a const char * Because you should not be modifying it. The same applies to dates in pickDates.

Later, where you have a series of sprintf / strcat, Do not use strcat, not a tmp training. You can write to date_str through a temporary pointer that increases according to the return value of sprintf.

I suggest reversing this logic:

yes (dd) < 32 && dd > 0 && mm < 13 && mm > 0 && yy> 0)
{
// ...
returns 1;
}
otherwise it returns -1;

to

yes (dd) < 0 || dd > 31 || mm < 0 || mm > 12 || yy <0)
returns -1;
// ...
returns 1;

Also, if that return value indicates success or failure, you must use a Boolean value of stdbool.h and use true / false instead of an integer.

Is:

int i = 0;
int dd = atoi (& date_str[i+1]);
int mm = atoi (& date_str[i+4]);
int yy = atoi (& date_str[i+7]);

dont have much sense; I it might not exist and could also do it

int dd = atoi (date_str + 1),
mm = atoi (date_str + 4),
yy = atoi (date_str + 7);