Implicit Declaration of Function ‘Atoi’?

Implicit Declaration of Function ‘Atoi’?

Why am I getting an error when using the atoi() function?

#include <stdio.h>
#include <string.h>
int main()
{
    char s1[10], s2[10];
    int x=5, y=6, z;
    sprintf(s1, "%d", x);
    sprintf(s2, "%d", y);
    strcat(s1, s2);
    z = atoi(s1);
    printf("%d, %s", z, s1);
    return 0;
}
3

1 Answer

#include <stdlib.h>

Will fix it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.