Unable to recognize char array sent through Serial com

I’m trying to get my arduino to recognize a character array sent from a C++ script (using windows API). The script sends a char array “hello\0” to the arduino. The arduino listens and stores everything up to the last ‘\0’ character. After which, it creates a character array of size: size(“hello”) to store the “hello” string.

int sizee, n, i = 0, j = 0;
char d[] = "poop\0";
char* S = new char[10];

void setup() {
  // put your setup code here, to run once:

void loop() {

     if( Serial.available() ){             // IF AN INPUT IS RECEIVED FROM C++ SCRIPT...
          char k = Serial.read();        // READ CHARACTER BY CHARACTER
          *(S+i) = k;                       // APPEND STORED CHARACTER TO DYNAMIC ARRAY (S)
          i += 1;                             // INCREMENT INDEX
          if(k=='\0'){                       // IF LAST CHARACTER IS REACHED...
               j += 1;                        // SWITCH j: ON
               sizee = i-1;                  // DEFINE SIZE OF NEW ARRAY
     if(j==1){                                // IF j: ON (ie IF LAST CHAR IS REACHED)...
          char u[sizee];                                  // CREATE CHAR ARRAY
          for(int p = 0; p <= sizee; p++){       
               u[p] = S[p];                               // COPY CONTENTS OF S --> u

          if(u =="hello" ){                                  // this is not recognized.. why...???
               Serial.println(" string recognized!");
          j += 1;

In the last if() statement, when I set the condition to look for just one character in the created character array (e.g u[0] == ‘h’), each separate character in “hello\0” is recognized and it works fine. but when i search for the whole string “hello” or “hello\0”, nothing is recognized.

Firstly, there is no such thing as a "C++ script". Secondly, you cannot use == to compare strings, you need the strcmp() function.

char* S = new char[10];

As opposed to

char S[10];



*(S+i) = k;  Is this an entry for an obfuscated code competion?

S [i] = k;is so much easier to read, don't you think?

Or even i[S] = k;if you're feeling only a little perverse.

if(k=='\0'){ It's fairly rare to send the null terminator.

The examples in Serial Input Basics are simple reliable ways to receive serial data.