Convert char array to string

I'm reading date and time from a cellular breakout and parsing the data into a char array. The date and time from the cell card is in the form of yr/mo/day,hr:min:sec. I send a couple of AT commands and the interaction goes as follows:

AT
OK
AT+CCLK?
+CCLK: "17/03/29,20:46:50-20"

OK

That time is accurate enough for this application and my test sketch has been very stable. However I would like to set my DS3231 RTC on startup and regular intervals using that cellular network time. I've found that I can create these variables to present to the RTC library for setting the RTC:

char yrX = 17;
char moX = 3;
char dayX = 28;
char hrX = 20;
char minX = 31;
char secX = 05;

I've hammered away at google etc for a few days and I'm coming up empty-handed looking for a technique to convert those cellular date and time values stored in an array into variables that the library will accept. I'm open to any suggestions to get it to work, whether it involves reading the cellular time directly into variables, reading into six separate arrays for the various elements of date and time, different RTC libraries, etc.

My test sketch:

#include <SoftwareSerial.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"

  SoftwareSerial Cellular(7, 8); // RX, TX

  int bufferBinCtr;

      //variables for setting the clock
char yrX = 17;
char moX = 3;
char dayX = 28;
char hrX = 20;
char minX = 31;
char secX = 05;

void setup()  {
  Cellular.begin(9600);
  Serial.begin(9600);

  Wire.begin();//Instantiate the RTC
  rtc.begin();

  bufferBinCtr = 30;//clear cellular buffer
  bufferBin(bufferBinCtr);

  rtcClockAdjust();//set the clock on startup
}
void loop()
{
    delay(9814);//some delay for testing, processes eventually to be scheduled by RTC

    ATCCLKPrint();//prints AT and AT+CCLK? to the cell

    ATCCLKRead();//read clock output from cell

    rtcClockRead();//read RTC
}

void ATCCLKRead() {

bufferBinCtr = 28;//wastes AT/AT+CCLK preamble
bufferBin(bufferBinCtr);

    char cbcArray[17];//date/time from cell is in the form of year/mo/dy,hr:mn:sc
    int count = 0;

    Serial.print("Network time is ");

    for(int z8z = 0; z8z < 18; z8z++)

if(Cellular.available() > 0) //test for bytes in buffer
{
  char C = Cellular.read();

     //a hyphen comes immediately after :sec
   if(C == '-') 
   {
     int i = 0;
     while (i != count) 
      {
         Serial.print(cbcArray[i++]);
      }
   }
   else  cbcArray[count++] = C; 
}

  Serial.println("");

  bufferBinCtr = 12;//burns extraneous bytes at end of buffer
  bufferBin(bufferBinCtr);
}
  void ATCCLKPrint() {
  bufferBinCtr = 30;
  bufferBin(bufferBinCtr);

  Cellular.println("AT");//send "AT", cell responds with "OK"
 delay(100);
 Cellular.println("AT+CCLK?");//request time from cell
  delay(100);
  }
  
  void bufferBin(int xx){
  for(int z8z = 0; z8z < xx; z8z++) {
  char z8 = Cellular.read();
  }
}
  void rtcClockRead(){
    Serial.print("RTC clk time is ");
  
    DateTime now = rtc.now();
    
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.date(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    delay(1000);
}

void rtcClockAdjust()
{
    DateTime dt(yrX, moX, dayX, hrX, minX, secX, 5);
    rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above 
}

Thanks in advance for your time.

Explore c functions such as strtok() and atoi()

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

sparkymarkm:

    for(int z8z = 0; z8z < 18; z8z++)

We don't charge extra for braces here.