0

I have an problem with declaring a string.

Arduino: 1.6.9 (Windows 10), Board: "Arduino/Genuino Uno"

readBinaryCode:3: error: 'string' does not name a type

string code = "10101010010010100101000101010101111100"

C:\Users\Jerel\Desktop\All\Sketchs\readBinaryCode\readBinaryCode.ino: In function 'void loop()':

readBinaryCode:12: error: 'code' was not declared in this scope

for(int i = 0; i < code.length(); i++) {...

exit status 1

'string' does not name a type

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

thor
  • 21,418
  • 31
  • 87
  • 173
  • Try `std::string`. I've done the Zuul joke already once today. And make sure `` is included. – user4581301 May 11 '16 at 00:37
  • Possible duplicate of [Weird string does not name a type Error C++](http://stackoverflow.com/questions/5527665/weird-string-does-not-name-a-type-error-c) – user4581301 May 11 '16 at 00:39

1 Answers1

0

Its telling you the truth.

 'string' does not name a type

Instead of

 `string code` use  `String code`



 void setup() {
      // put your setup code here, to run once:
    String code = "10101010010010100101000101010101111100";

    }

Update we dont need any to include anything for this

Ccr
  • 686
  • 7
  • 25
  • I am extremely dubious about what you are suggesting. `string.h` is a C standard library header containing `strcpy` etc. `string` is a C++ class template from `string`. I've not programmed on the Arduino but I would be surprised if they hijacked a C library header and started stuffing it with classes that replicated what C++ does. – graham.reeds May 11 '16 at 07:23
  • I got tht. we dont need that include statement. And yes you were right about the string.h. My bad. – Ccr May 11 '16 at 07:47