Char array part's extraction

Hi all,

i'm confused with extracting a part of a char array, please i need help:

char * Test;
Test = "1082";

i want to extract the number contained in the variable Test (1082), without the "", it can be from 3 numbers to 5, i tried many commands in C++ but i always get an error or wrong result.

may you have an idea, how to do ?

Thanks

may you have an idea, how to do ?

If you want the entire string converted to an int, that is trivial:

int val = atoi(Test);

If you want a part of a string converted to an int, you need to define which part.

Thanks for reply,

but the reported result is 0,

may have another idea ?

Thanks

As you ask we need to extract the part of the string from char [1] to char [4]

Thanks

Paul’s suggestion works for me:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  char * Test;
  Test = "1082";
  int val = atoi(Test);

  Serial.print("val = ");
  Serial.println(val);
}

void loop() {
  // put your main code here, to run repeatedly:

}

but the reported result is 0,

Then you did it wrong.

may have another idea ?

OK. I have an idea that you need to post your code. Make it so.