如何将hypen插入到这样的字符串中 01201997
并将其设为01-20-1997
到目前为止,我有这个void datef(char string[])
{
char strFinal[50];
char *strB = "/", *strA[3]; // declare two strings you will join plus a third string to put in
int x = 3; // declare integer to tell program how many characters you want to insert your string into
int y = 5;
strncpy(strFinal,string,x);// copies the first X characters into the strC, you have to add the null
strFinal[x] = '\0'; // adds the null
strcat(strFinal,strB); // copies the second half of the string
strcat(strFinal,string+x); // another part to copy the remaining part of the string
strncpy(strFinal, string, x);
printf("%s\n",strFinal); // prints string
}