consider the following two code:
void PrintLetter(char *src)
{
while(*src != '\0')
{
printf("%c",*src);
src++;
}
}
and
void PrintLetter(char *src)
{
int i;
for(i=0;src[i];i++)
printf("%c",src[i]);
}
Is there any performance difference between the two?
None whatsoever. The compiler will perform its optimizations regardless of the form you are writing. The underlying assembly code is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With