Change for(int i=0; i<n; ++i) to a format compatible with C.