How to use null?


I tried using string to declare a variable.

String a = null;

I received compilation error: 'null' was not declared in this scope

I do not how to use null for coding, I hope you can help me please. Thanks.

To start, please next time only post whole in code tags sketches because most of the time the error is not in the snipped. See How to use this forum and

I tried using string to declare a variable.

No you don't :wink: You tried to use String! Note the capital?

Also, you don't want to use NULL (again, devil is in the details) for strings or Strings. You want to use an empty null terminated string "" or the ASCII null-character '\0'.

And I don't know what you want to put in "a" but it's a terrible variable name... Make it reflect what it holds (but that might be just for the example.

And I would advice note to use String but stick to c-style strings.

char myText[10] = ""; //empty string that can hold 9 character + the null-character '\0'

What is null - perhaps you meant the macro NULL, or 0