0

what is the problem in arduino

C:\Users\swartwq\Desktop\zx\sketch_jun06e\sketch_jun06e.ino:12:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Brian61354270
  • 8,690
  • 4
  • 21
  • 43
  • 1
    Does this answer your question? [Conversion from string literal to char\* is deprecated](https://stackoverflow.com/questions/13690306/conversion-from-string-literal-to-char-is-deprecated). Same diagnostic, different compiler. You're trying to convert a string literal (which has type `const char[]`) to a pointer to a mutable `char` (i.e., `char *`). – Brian61354270 Jun 06 '21 at 19:40

1 Answers1

0

In C++

char* a = "a"; //invalid
const char* b = "b"; // valid
char c[] = "c"; //valid

The reason why the first line is invalid is that a is a pointer to static read-only data and therefore is wrong to be non-const. C on the other hand is ok because the string "c" is allocated immediately on the stack and can therefore be changed.

doron
  • 27,972
  • 12
  • 65
  • 103