Stupid C question

Why does this not work...

case 'R': {
        char resolution[12] = {'\0'};  // no "R"


        for (int i = 0 ;Serial.available() > 0 ;i++ ){
          resolution[i] = Serial.read();
                          
        }
        Serial.println(resolution);        
        // tab in [5]
        resolution[5] =  '\0';
        resolution[11] =  '\0';
        for (int x = 0;x<11;x++){
           Serial.println(resolution[x], BYTE);
        }
        
        DECSteps = atoi((char*)resolution);
        RASteps = atoi((char*)(resolution[6]));  
        Serial.println(DECSteps); //debug out
        Serial.println(RASteps); //debug out
        
        
        //respond to command
        Serial.write("R");
        Serial.flush();  // one can never be too sure...
        break;

On an input of "R12345x67890" I get:

number of characters in buffer:1
12345x67890
1
2
3
4
5
null
6
7
8
9
0
12345
0
R

At the end I'm expecting
12345
67890
R

Is this not valid?

RASteps = atoi((char*)(resolution[6]));

I'm thrashing here, help appreciated!

If you change to

DECSteps = atoi((char*)resolution[0]);

does that one fail as well?

Yes - hmmm....

I get:

0
0
R

Also, this

        DECSteps = atoi((char*)resolution);
        char* raString = &resolution[6];
        
        RASteps = atoi((char*)(raString));  
        Serial.println(DECSteps); //debug out
        Serial.println(RASteps); //debug out

Gives
12345
2354
R

I think your problem is earlier up:

        for (int i = 0 ;Serial.available() > 0 ;i++ ){
          resolution[i] = Serial.read();
                          
        }

I think that's only ever going to get 1 character at a time because the loop operates much faster than characters can arrive.

This seems to work:

char resolution[12] = {'1','2','3','4','5',0,'3','2','1','2','3',0};

int DECSteps = atoi(&resolution[0]);
int RASteps = atoi(&resolution[6]);

But I'm getting them all as per the output in the original:
12345x67890
1
2
3
4
5
null
6
7
8
9
0

My K & R second edition is failing me on pointers and char[]!
P.

Note that

2354 is 0x932

and

67890 is 0x10932

This:

case 'R': {
        char resolution[12] = {'\0'};  // no "R"


        for (int i = 0 ;i < 12 ;i++ ){
          resolution[i] = Serial.read();
                          
        }
        Serial.println(resolution);        
        // tab in [5]
        resolution[5] =  0;
        resolution[11] =  0;
        for (int x = 0;x<11;x++){
           Serial.println(resolution[x], BYTE);
        }
        
        DECSteps = atoi(&resolution[0]);  
        RASteps = atoi(&resolution[6]);  
        Serial.println(DECSteps); //debug out
        Serial.println(RASteps); //debug out

Gives me:
12345x67890ÿÂ
1
2
3
4
5
null
6
7
8
9
0
12345
2345
R

Note that

2354 is 0x932

and

67890 is 0x10932

Yep - that was it - overflow...

It does work as expected with smaller numbers, thank you!