# How does one split a string into more than only 2 values?

**URL:** <https://forum.arduino.cc/t/how-does-one-split-a-string-into-more-than-only-2-values/624012>\
**Category:** Programming\
**Created:** [December 3, 2019, 6:04am UTC](https://forum.arduino.cc/t/how-does-one-split-a-string-into-more-than-only-2-values/624012 "2019-12-03T06:04:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Arduino\_n00b](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@Arduino\_n00b](https://forum.arduino.cc/u/Arduino_n00b)\
**Post date:** [December 4, 2019, 6:01am UTC](https://forum.arduino.cc/t/how-does-one-split-a-string-into-more-than-only-2-values/624012/2 "2019-12-04T06:01:43Z")

</div>

I have yet to see anything concise (IMHO) as to how one goes about splitting a String into more than 2 places so that each substring as it were can be printed to the Serial monitor accordingly.

And here's something for the code-snippets page...

```cpp
    // Split string into five values - HOW??????????
    for (int i = 0; i < str_out.length(); i++ ) {
      if (str_out.substring(i, i + 1) == ",") {
        str_Ctemp1 = str_out.substring(0, i);
        str_Ftemp1 = str_out.substring(i + 1);// I got lost from here on down up to but limited by break;
        str_Ctemp2 = str_out.substring(1, i);  // Definitely wrong...
        str_Ftemp2 = str_out.substring(i + i);  // Definitely wrong...
        str_humid = str_out.substring(2, i);    // Definitely wrong...
        break;
      }
    }

    // Print values to Serial Monitor
    Serial.print("C = ");
    Serial.println(str_Ctemp1);
    Serial.print("F = ");
    Serial.println(str_Ftemp1);

    Serial.print("C2 = ");
    Serial.println(str_Ctemp2);
    Serial.print("F2 = ");
    Serial.println(str_Ftemp2);
    Serial.print("Hum = ");
    Serial.println(str_humid);

```

If the entire code(s) are needed for clarity on your part, then I can provide that as well.

Any pointing in the right direction is appreciated.

---

_[View the full topic](https://forum.arduino.cc/t/how-does-one-split-a-string-into-more-than-only-2-values/624012)._
