String... need your help..

Hi... it's kinda new to me what method to use to get the first 2 characters of char/string, then get the 4th place to 15th place of the char/string in the new char/string. Then covert the first string we got to byte and second string to char if the data type is string.

example: String stringOne = "10 92845401834";
String stringTobyte;
String stringTwo;

i want this result.
StringTobyte = 10;
StringTwo = 92845401834;

A cheap pointer abuse will work well. Avoid the String library once you are comfortable with arrays and pointers.

String stringOne = "10 92845401834";

stringOne[2] = '\0';

String stringTobyte = &stringOne[ 0 ];
String stringTwo = &stringOne[ 3 ];

//Fix up stringOne
stringOne[2] = ' ';

Thank you for your answer..

How to convert stringTobyte to byte,
Then stringTwo to char?

byte = unsigned char, maybe you want uint64_t ( unsigned long long ) as 92845401834 requires 37 bits of storage.

you need to look for the function atoi, fine for the '10' but it wont support 64 bit values ( also, atol is no good ), here is the first topic I found on google:

No, I need a byte. Byte can only store 0 to 255 is that right? that's why i only need 2 character from the string..

atoi will do what you want for the byte:

    Serial.begin( 9600 );
    
    String stringOne = "10 92845401834";
    
    stringOne[2] = '\0';
    
    String stringTobyte = &stringOne[ 0 ];
    String stringTwo = &stringOne[ 3 ];
    
    //Fix up stringOne
    stringOne[2] = ' ';
    
    byte b_Data = atoi( &stringTobyte[ 0 ] );
    Serial.print( "byte: " ); 
    Serial.println( b_Data );

wow thank you... what about the string to char sir?

I’m not sure what you are expecting.
The long number is too big for a char, and too big for atoi to turn to an int.

if you want a pointer to the char array, you can use:

char *c_array = &stringTwo[ 0 ];

Sir... it doesn't get all char from 4th to last char..

Result.
stringOne=10 +63901280235

byte = 10

StringTwo= +639012

Am I missing something?

I place exactly the code you had given..

Maybe you are running out of memory or something else is causing a problem.
If I add 'Serial.println( stringTwo );' to the end of the code in reply #5, it prints out:

byte: 10
92845401834