[Solved] Reverse the order of an integer in C [closed]


You can just read it in as a string.

int main()
{
    char str[80];
    fgets(str, 80, stdin);
    strrev(str);
    printf("%s\n", str);
}
void strrev(char *str)
{
    char *end, tmp;

    end = str + strlen(str) - 1;

    for (; end > str; --end, ++str) {
        tmp = *end;
        *end = *str;
        *str = tmp;
    }
}

I don’t know if you consider pointer arithmetic to be “arithmetic”

solved Reverse the order of an integer in C [closed]