I am new to programing, and still learning the basics and figuring out best practices for C language. For iterating through string's characters i know of two ways, which is better and why?
int letters = 0, i = 0;
while (text\[i\] != '\\0')
{
if (isalpha(text\[i\]))
{
letters++;
}
i++;
int letters = 0, i = 0;
while (text[i] != '\0')
{
if (isalpha(text[i]))
{
letters++;
}
i++;
}
I tried both methods and both worked, but not sure which works better.
Aucun commentaire:
Enregistrer un commentaire