// http://www.robotronix.co.il לימוד ארדואינו מחרוזות


void setup() {
  Serial.begin(115200);
  
  // Convert char array to String
  char buf[100];
  strcpy(buf,"Hello, Robotronix.co.il");

  //convert from buf array to string 
  String str = String(buf);

  // Convert String to char array
  char buf2[100];
  str.toCharArray(buf2, sizeof(buf2));

  // Compare two strings
  String str1 = "12232";
  String str2 = "12334";
  int result = str1.compareTo(str2);
  if (result == 0) {
    Serial.println("Strings are equal");
  } else if (result < 0) {
    Serial.println("String 1 is smaller");
  } else {
    Serial.println("String 2 is smaller");
  }

  // Copy one string to another
  String source = "Copy this";
  String destination = source;

  // Search for a string in another string
  String sentence = "http://www.robotronix.co.il is good place to learn robotics";
  if (sentence.indexOf("learn") != -1) {
    Serial.println("Found 'learn' in the sentence");
  } else {
    Serial.println("Could not find 'learn' in the sentence");
  }

  // Add one string to another
  String string1 = "http://";
  String string2 = "www.robotronix.co.il";
  String combined = string1 + " " + string2;
  Serial.println(combined);
    combined.toCharArray(buf2, sizeof(buf2));

}

void loop() {
  // Empty loop
}