c++ - Store numericals in TCHAR array into an INTEGER variable in VC++. (in UNICODE environment) -
i had asked question similar in thread: https://stackoverflow.com/questions/11259474/store-the-numericals-in-char-array-into-an-integer-variable-in-vc
w.r.t. above thread, question follows:: working in unicode environment. tchar treated wchar.
my scenario follows:(c++)
in tchar a[10], array a[] has elements (numbers) '1','2','3' etc....
say a[0] = '1'; a1 = '2'; a[2] = '3';
now a[] storing 3 characters '1', '2' , '3'. want store int 123 (an integer 123).
how achieve in c++ ?
thanks in advance.
first, have null-terminate string. otherwise, how know stop? there's function _ttoi()
that.
a[3] = 0; int n = _ttoi[a];
you have understand null termination bit. depending on how fill a
characters (digits), logic of determining end of string might vary.
Comments
Post a Comment