You can do this with
char x[4];
int i;
strcpy(x, "123");
i = atoi(x + 1);
Because x
is a pointer to char, x + 1
is a pointer to the next char. If you try to print with
printf("%s", x + 1);
You'l get 23
as the output.
Note though that you need to declare the length of the char array to be one more than the number of characters in it - to accommodate the ending \0
.