user46364: After I take a char* variable from serial communication, I use strtok to split variables with " ". But when I do that it acts like there is a " " after every character. I dont know why. How can I fix this ?
void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  char* a = "The quick brown fox jumped over the lazy dog.";
  char* c = a3;
  char* b;
  b = strtok(c, " ");
  while (b != NULL) {
    Serial.println(b);
    b = strtok(NULL, " ");
  }
}

void loop() {
}

outcome:
The
quick
brown
...

This parsing code works perfectly, until I take it from serial ports. Serial code here, like this:
#include <SoftwareSerial.h>
#define bRSerial 9600
#define bRmY 9600

char vD[45];
int i = 0;

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(bRSerial);
  while (!Serial) {
    ;
  }
  mySerial.begin(bRmY);
}

void loop() {
  if (mySerial.available()) {
    //Serial.write(mySerial.read());
    vD[i]=mySerial.read();
    i++;
    if (i = 46) {
      char* a = vD;
      char* b;
      
      b = strtok(a, " ");
      while (b != NULL) {
        Serial.println(b);
        b = strtok(NULL, " ");
      }
      i=0;
    }
  }
}

outcome:
T
h
e
q
u
i
c
k
b
r
o
w
...

Is there a way to fix this? i need to get it from serial and split on " ".

user37622: only a syntax typo. the condition should be if ( i == 46 ) {
if this is not only a strtok test, the you do not need strtok. read in char c, and if c == ' ', print vD and reset i to 0
and I do not see where you set the terminating 0 of vD a.k.a. a

46364: <p>After I take a char* variable from serial communication, I use <code>strtok</code> to split variables with &quot; &quot;. But when I do that it acts like there is a &quot; &quot; after every character. I dont know why. How can I fix this ?</p>
<pre><code>void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  char* a = &quot;The quick brown fox jumped over the lazy dog.&quot;;
  char* c = a3;
  char* b;
  b = strtok(c, &quot; &quot;);
  while (b != NULL) {
    Serial.println(b);
    b = strtok(NULL, &quot; &quot;);
  }
}

void loop() {
}
</code></pre>
<p>outcome:</p>
<pre><code>The
quick
brown
...
</code></pre>
<p>This parsing code works perfectly, until I take it from serial ports. Serial code here, like this:</p>
<pre><code>#include &lt;SoftwareSerial.h&gt;
#define bRSerial 9600
#define bRmY 9600

char vD[45];
int i = 0;

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(bRSerial);
  while (!Serial) {
    ;
  }
  mySerial.begin(bRmY);
}

void loop() {
  if (mySerial.available()) {
    //Serial.write(mySerial.read());
    vD[i]=mySerial.read();
    i++;
    if (i = 46) {
      char* a = vD;
      char* b;
      
      b = strtok(a, &quot; &quot;);
      while (b != NULL) {
        Serial.println(b);
        b = strtok(NULL, &quot; &quot;);
      }
      i=0;
    }
  }
}
</code></pre>
<p>outcome:</p>
<pre><code>T
h
e
q
u
i
c
k
b
r
o
w
...
</code></pre>
<p>Is there a way to fix this? i need to get it from serial and split on &quot; &quot;.</p>
 37622: <p>only a syntax typo. the condition should be <code>if ( i == 46 ) {</code></p>

<p>if this is not only a strtok test, the you do not need strtok. read in char c, and if <code>c == ' '</code>, print vD and reset i to 0</p>

<p>and I do not see where you set the terminating 0 of <code>vD</code> a.k.a. <code>a</code></p>
