How do i turn a cstring into intiger?

How do i turn a cstring into intiger in C++. Cstring containing only numbers. Exaple s=3214;
How do i turn that cstring 3214 to intiger?

Read Here. You can simply use atoi function if you are using C++.

Another method is to traverse the string and subtract 48(ASCII value for number 0) or ‘0’ from each characted of the string to get the integer value and store it in a array.

1 Like