You have to include stdlib.h
#include <stdlib.h>
Next time you encounter similar warnings just run man atoi and the manual pages should state that which header file should be included.
man atoi