let's have char x[3] = "123"; , convert index 1 , index2 "23" of char array, can atoi?
i know can char z[2]; z[0]=x[1]; z[1]=x[2]; atoi(z); not asking for.
you can with
char x[4]; int i; strcpy(x, "123"); = atoi(x + 1); because x pointer char, x + 1 pointer next char. if try print with
printf("%s", x + 1); you'l 23 output.
note though need declare length of char array 1 more number of characters in - accommodate ending \0.
Comments
Post a Comment