Source: https://mokxi.com/errors/cannot-convert-string-to-const-char
Updated: 2026-11-16

Home / Errors
Arduino build error

# error: cannot convert 'String' to 'const char*'

An Arduino String is an object. Functions from the C library, such as strlen, strcmp and atoi, want a plain character array, a const char*.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes
- Seen 487 times in failed builds on Mokxi in the 30 days to November 16, 2026.

The message

## What the Arduino IDE prints

Output window

The two are different types, so the compiler will not pass one for the other. A String can hand over its characters with c_str().

Mokxi's compiler, clang, words it as no viable conversion from String to const char *.

Causes

## The 2 usual causes with the fix

### 1A String is passed to a C string function

strlen, strcmp, strcpy and atoi take a const char*. Call c_str() on the String to get one, or use the String methods such as length().

Broken

Fixed

Mokxi’s build tab says: strlen takes C text

Try this fix in Mokxi

### 2A String is passed to your own function that wants const char*

A function declared with const char* will not take a String. Change the call, or write the function to take a String.

Broken

Fixed

Mokxi’s build tab says: show takes C text

Try this fix in Mokxi

FAQ

## Questions and answers

### What does "cannot convert 'String' to 'const char*'" mean?

A function that wants a plain C string was given an Arduino String object. Call c_str() on the String to pass its characters.

### What is the difference between String and char arrays?

A String is an object with methods such as length() and concat(). A char array is a row of bytes that ends in zero. C library functions only know the second.

### Should I use String at all on an Uno?

Short, fixed strings are fine. A sketch that joins many Strings in loop() can fragment the 2 KB of memory, so plain char arrays are safer there.

Next

## More errors and the longer guide

- error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
- error: no matching function for call to 'digitalWrite(int)'

The longer guide to this error All Arduino errors
