I have to cut the day month and year out of a date string (mm/dd/yy). I can get the piece of the array out and print it using "printf ("%s\n",pch);" but how would I assign it to a variable instead of print it out.
pch = strtok (str,"/");
while (pch != NULL)
{
counter = 0;
printf ("%s\n",pch);// this line works and prints out the correct data
pch = strtok (NULL, "/");
if (counter = 0)
strcpy(day, pch);//here i need to assign the first piece to day
else if (counter = 1)
strcpy(month, pch);//here i need to assign the second piece
else if (counter = 2)
strcpy(year, pch);//here i need to assign the third piece
counter++;
}
Can anyont point me in the right direction to copy the tokenized array?