0

I'm about identify myself stupid, howcome I couldn' t figure out how to split a string into substring using arduino, even after 10 days of searching. The number is fact... So, As Mr.Arduino.cc says: string.substring() is just can be used as conditional phrase with loops like if. and there is no method such strtok() like in C can help me with this. So guys, I' m bagging you for help, please!

if (ks > 255 * 60)
 {
 vek.print("Bu yazı, ", 25, 0);
 vek.printNumI(255*60, 25, 8);
 vek.print("karakterd-", 25, 16);
 vek.print("en uzun ol", 25, 24);
 vek.print("dugundan", 25, 32);
 vek.print("gosterlemz", 25, 40);
 }
for (byte i = 0; i <= ss ; i ++)
 {
 for (byte j = 0; j <= 6; j++)
 {
 int ilk_kar = j * 10 + i * 60;
 int son_kar = ilk_kar + 10;
 String yaz=readString.strtok(ilk_kar,son_kar);
 vek.print(yaz, 25, j);
 if (analogRead(A5) == 1023)
 {
 continue;
 }
 else
 {
 break;
 }
 }
 }
 }
}

Error: sketch_aug22a.ino: In function ‘void loop()’: sketch_aug22a.ino:83:56: error: ‘class String’ has no member named ‘strtok’

What am I supposed to do?

Thanks, already...

James Waldby - jwpat7
8,9203 gold badges21 silver badges33 bronze badges
asked Aug 21, 2016 at 19:15
9
  • Do you want to split the string on a particular character or position? Commented Aug 21, 2016 at 19:53
  • 1
    You can use strtok(). It's not part of the Arduino core library: it's just a libc function. Commented Aug 21, 2016 at 20:02
  • And, how am I supposed to find that libc (I guess a library) thing? Commented Aug 21, 2016 at 20:45
  • Mr.Bonet, pls, I need this answer... Commented Aug 21, 2016 at 20:49
  • It would help to have the above questions answered. Do you want to split at a certain spot (eg. 5th character)? Or after certain symbols (eg. a comma)? Commented Aug 21, 2016 at 20:52

1 Answer 1

1

Import the string.h library by adding #include <string.h> on top of your sketch, in order to use the strtok() function. Checkout the usage example of strtok() here: http://www.cplusplus.com/reference/cstring/strtok/?kw=strtok

answered Aug 22, 2016 at 7:54
2
  • in arduino ide? Commented Aug 22, 2016 at 9:49
  • Yes, of course. Commented Aug 22, 2016 at 11:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.