My scenario is as follows:(C++)
In char a[10], the array a[] has elements (numbers) like ‘1’,’2′,’3′ etc….
Say a[0] = ‘1’;
a[1] = ‘2’;
a[2] = ‘3’;
Now a[] is storing 3 characters ‘1’, ‘2’ and ‘3’. I want to store this into an int as 123 (An integer 123).
How to achieve this in C++ ?
a[3] = 0is a must. If your string isn’t null-terminated, most methods won’t work.After that, it’s a simple
number = atoi(a)