Convert to int part of 1000 digit long numer defined in char array

hi

please how do i convert just the number from position 4 to 15 from this char array and convert to int and save to variable

char numbers[]="54155444546546545643246543241465432165456";


the real char got 1000 digits this is just example how do i convert chars from numbers[4] to numbers[15] and save them as one number ? in this case i will get int x = 5444546546545643 as u can see char numbers as a example above
how about this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	int get_num(char *in, int isize) 
	{ 
		int res = 0, sign = 1, i = 0;
		if (in[0] == '-') { sign = -1; i++; }
		for(; i < isize; ++i  )
		{
			if( !isnum(in[i]) ) break;
			res = res*10 + in[i] - '0';
		}
		return sign*res;
	}

char numbers[]="54155444546546545643246543241465432165456";
void something()
{
    int n = get_num(&numbers[4],15-4)
}
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>

const char numbers[] = "54155444546546545643246543241465432165456";

int main()
{
    std::cout << std::stoll(std::string{numbers + 4, numbers + 16});
}

Last edited on
@ OP: CAUTION Don't just copy and paste the answer from MiiNiPaa, he did leave a tiny bit of work for you to figure out on your own. It's up to you to figure out what that is.
yea i wont copy anything i just want to see the principe of it how do i do that , and also who is MiiNiPaa he knows absolutely everything he answers every topic he is rly geek , is he owner of this site ? i love him how old is he ?
Topic archived. No new replies allowed.