I have a date in the format of YYYY-MM-DD as a string (including the hyphens)

How do I split this string just to obtain YYYY, MM and DD separately? Possible use of an array or something?

Would really appreciate some help :)

Edit: Nevermind, just discovered the explode() function :P

Use index and rindex functions as given here and a little string handling can serve your purpose.

#define ERROR(X) printf("%s Failed\n", X)

int main()

	char *month;
	char *year;
	char *date = "dd-mm-yy";

	month = index(date, '-');
	if (month == NULL)
	year = rindex(date, '-');
	if(year == NULL)

	printf("date = %s month = %s yeat = %s\n", date, month, year);
	return 0;