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.
2 Respostas
+ 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';
}
+ 1
~ swim ~ yes it's a number string in the form of '1 2 3 4' . Thank you .