jeudi 2 février 2017

Why does this for-loop in my function will only run once, even when it's supposed to run multiple times?

Could someone explain to me why this for-loop only runs one time no matter what n is:

double CalcDist(unsigned int n, Point p, Point* s)
{
    double sd[n];
    for(int i = 0; i < n; i++)
    {
        sd[i] = s[i].Dist_To(p);
        return sd[i];
    }
}

Thanks in advance for any help.

Aucun commentaire:

Enregistrer un commentaire