secondo me l'errore è nell' if :
codice:
if (c=1) //sbagliato

if (c==1) //giusto