How could I change an array of character (string) to an integer number without using any ready function (ex atoi();) for example :-
char a[5]=\'4534\';
I prefer to use the std::atoi()
function to convert string into a number data type. In your example you have an non-zero terminated array "\0"
, so the function will not work with this code.
Consider to use zero terminated "strings",
like:
char *a = "4534";
int mynumber = std::atoi( a ); // mynumber = 4534