NVIDIA Interview Question
Software Engineer / DevelopersI think you missed the check of string length versus pos,
add a line to
{
if (pos > 0 && pos < strlen(source))
{
source += pos;
for (;len>0;len--)
{
*(dest++) = *(source++);
}
*dest=0;
}
}
void mysubstr(char *dest, char *source, int pos, int len)
- Anonymous August 11, 2011{
while(len>0){*dest=*(source+pos);
*dest=*source;
dest++;source++;len--;}
*dest='\0';}