I finished the Initials (more comfortable) problem, but when trying to detect initials, I'd like to avoid negative indeces.
Here's what I used for the detection of initials, if it's not a space at first index.
if (i == 0 || name[i-1] == 32)
{
printf("%c", toupper(name[i]));
}
Could it be an issue already, if i==0 and I use a condition refering to index [-1]? Would it be safer to split it up like this?:
if (i == 0)
{
printf("%c", toupper(name[i]));
}
else if (name[i-1] == 32)
{
printf("%c", toupper(name[i]));
}
If I were to allow the access of a negative index. What exactly happens and how can this cause issues?
Thanks