לימוד ארדואינו : שיעור 8 – מחרוזות קורס C506 – פיתוח אמבדד
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/* www.Robotronix.co.il c506 learn c */ void setup() { Serial.begin(115200); // open the serial port at 115200 bps: // print string Serial.print("Hello"); // prints a label } void loop() { } |
דוגמא 2 לימוד מחרוזות – פיתוח אמבדד
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
/* www.Robotronix.co.il c506 learn c */ #include <stdio.h> #include <string.h> char user[30]; char email[40]; char password[20]; char age[5]; void setup() { Serial.begin(9600); // open the serial port at 115200 bps: // user strcpy(user,"Shelomo"); // email strcpy(email,"dev@robotronix.co.il"); // paasword strcpy(password,"!!-1"); // age strcpy(age,"18.5"); // ------------------------------ // Output print infromation Serial.print("Name : "); Serial.println(user); Serial.print("Email : "); Serial.println(email); Serial.print("password : "); Serial.println(password); Serial.print("Age : "); Serial.println(age); // --------------------------------- // check if password is bigger then 4 chars // strlen() // https://www.tutorialspoint.com/c_standard_library/c_function_strlen.htm Serial.print("password lenght : "); Serial.println(strlen(password)); if (strlen(password )<=4) { Serial.print("password is too small (weak ) "); } else { Serial.print("password is o.k bigger then 4 chars "); } } void loop() { } |
דוגמא 3 – מחרוזות בדיקת אורך מחרוזת Strlen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* www.Robotronix.co.il c506 learn c */ #include <stdio.h> #include <string.h> char password[5]; // 4 chars + 1 NULL =0 total 5 void setup() { Serial.begin(9600); // open the serial port at 115200 bps: Serial.println(); if (strlen(password )<=4) { Serial.print("password is too small (weak ) "); } else { Serial.print("password is o.k bigger then 4 chars "); } } void loop() { } |