I was studying strcat_s
and I wrote the following code to practice it.
int main(void)
{
char szPath[128] = { "C:\\Program Files\\" };
strcat_s(szPath + strlen("C:\\Program Files\\"), sizeof(szPath), "CHS\\");
strcat_s(szPath + strlen("C:\\Program Files\\CHS\\"), sizeof(szPath), "C programming");
puts(szPath);
return 0;
}
The output worked properly like
C:\Program Files\CHS\C programming
but a debug error window popped up,
Stack around the variable 'szPath' was corrupted.
What is the cause?