Microsoft Interview Question
Software Engineer in Tests1)
if(pch[i]=='A' || pch[i]=='a')
ret++
else
/* there should not be this else, because we have increase the index anyhow to check the next character*/
i++
2) also tmpvar is int and len in unsigned long.. might cause problem
Also in the line
f(*pch==NULL || !strcmp(pch," "))
the "!" should not be there for the strcmp() check because, we should return 0 if pch is an empty space.
My Answer is that in this do-while loop will go in indefinite loop as value of 'i' is not getting increment in case when 'a' or 'A' is encountered.. you guys can you figure out some other bugs ???
- ajitpec January 29, 2011