The problem is that atol expects a char* not a char. I'm surprised the code you posted even compiles, I am sure it doesn't compile without warnings.
You could just take a pointer to your char
Problem with that is atol doesn't just expect a char* it expects a pointer to a C string, that is a zero terminated array of char which you do not have you have a single char. You could convert it to a string
-
char buffer[2];
-
buffer[0] = x;
-
buffer[1] = '\0';
-
out=atol(buffer);
-
But personally I find it rather long winded. As long as you are sure there is a digit character in your variable then you can just rely on the language guarantee that digit character values are contiguous (i.e. '1' = '0' + 1 ...)