Problems with exercise atoi ()


I'm having problems with this simple loop exercise. I think the code is correct and I don't get any errors however when I run the program, I just get "^C" over and over again. Please help.

#import <readline/readline.h>
#import <stdio.h>
#include <stdlib.h>

int main(int argc, const char * argv[])
    printf("Where should I start counting? ");
    const char *numInput = readline(NULL);
    int countDownStart = atoi(numInput);
    for (int i = countDownStart; i >= 0; i--) {
        if (i % 3 == 0){
            printf("%d\n", i);
            if (i % 5 == 0) {
                printf("Found one!\n");

    return 0;


UPDATE 8/3/14

The code works when I enter the starting number using the numbers above my keyboard. However when I enter the starting number with my 10 key, I get "^C" every time I hit enter. Now I'm completely flummoxed but at least my code works.

Thank you for the help everyone. I understand atoi is not the best function to use but am trying to work through the Big Nerd Objective-C book.

Use strtol inplace of atoi as it returns error value in case of conversion failures.