Let x+= n * p [I]; Change it to x+= n * (p [I]-'0'); .
It is best to put GETS (s); Change to scanf("%s ",s); .