unsigned long A = (long) strtol(str.c_str(),NULL,0);
Why not use B but some function call which we can't see?
Why cast the damn thing to a singed int again?
Why not use a real null pointer 'nullptr'?
Serial.println("this is B");
Serial.println(A);
Why print A if you tell it's B?
Questions questions questions...