strtok help

I need to convert a date from MM/DD/YYYY to Month DD, YYYY. I've used strtok to separate each part of the date but I'm confused on how to evaluate the first part as well as displaying the entire date.

1
2
3
4
5
6
7
8
9
10
{
	
	char* tok = strtok(birthday, "/");
	
	while (tok) {
	 printf("%s\n", tok);

	 tok = strtok(NULL, "/");
	 
	}
I'm confused on how to evaluate the first part

The first pass through your loop, tok is going to point to the MM part of birthdate, with the / replaced by a \0. You deal with this just like you would any other ASCII to binary conversion. atoi or scanf can be used to read in the month part.

as well as displaying the entire date

Once you've called strtok, the original birthday string has been modified (\0s have been inserted), so you're going to need to either convert the day and year to binary on the second and third passes through the loop, or save pointers to those strings. Finally, you going to have to reconstruct the date from the appropriate month name and remaining values.;
Topic archived. No new replies allowed.