+ 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.

15th Sep 2020, 1:35 PM
Bittu Kumar
Bittu Kumar - avatar
7 Respostas
+ 3
Bhavya Sarraf check the language in tags. He wants answer in "C" language
15th Sep 2020, 2:06 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 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
15th Sep 2020, 2:26 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
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.
15th Sep 2020, 10:43 PM
LastSecond959
LastSecond959 - avatar