0

String to Integer array

Hey I needed some help. How do I convert the string into an integer array in C++ ? I'm taking the string from command line . Edit : After conversion I'm facing problem with the array storage. I've used a for(i=0;str.length();i++) to display the integer array since arr where the array is stored won't have length / size function.

22nd Aug 2019, 3:20 PM
Sreyashi Bhattacharjee
4 Respuestas
+ 5
atoi() convert a char array to int int x=0; this is how to convert it manually string str="543; for(int i=0;i<str.length();i++) { x*=10; x+=str[i]-'0'; }
22nd Aug 2019, 4:18 PM
ABADA S
ABADA S - avatar
+ 1
~ swim ~ yes it's a number string in the form of '1 2 3 4' . Thank you .
22nd Aug 2019, 3:48 PM
Sreyashi Bhattacharjee