+ 4
Can anyone write a function which converts a string ex. "10254" to an integer (10254)?
You may use any procedure (dynamically or statically) to solve this problem using C language.
7 ответов
+ 3
Bhavya Sarraf check the language in tags.
He wants answer in "C" language
+ 2
Bhavya Sarraf you can tag/mention someone by typing @ and then a popup list will come up then choose a name from give list or type the initial for desired name
0
As Martin Taylor stated that you can use atoi() function which stands for ASCII to Integers, you can do it too aside from using atoi().
Here's how (try to make the code on your own):
1. Declare an int and init it with value 0 (ex: int num)
2. Make a loop from str[0] to str[len-1] or to null
3. Inside the loop, multiply num with 10.
4. Add num to (str[x]-'0')
If you a question about my answer, feel free to reply.